Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindarmour
提交
0b17c39d
M
mindarmour
项目概览
MindSpore
/
mindarmour
通知
4
Star
2
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindarmour
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0b17c39d
编写于
8月 21, 2020
作者:
J
jin-xiulang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix several api issues
上级
339595a3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
6 deletion
+11
-6
mindarmour/fuzzing/fuzzing.py
mindarmour/fuzzing/fuzzing.py
+4
-3
mindarmour/fuzzing/model_coverage_metrics.py
mindarmour/fuzzing/model_coverage_metrics.py
+1
-1
mindarmour/utils/logger.py
mindarmour/utils/logger.py
+5
-1
mindarmour/utils/util.py
mindarmour/utils/util.py
+1
-1
未找到文件。
mindarmour/fuzzing/fuzzing.py
浏览文件 @
0b17c39d
...
@@ -93,7 +93,7 @@ class Fuzzer:
...
@@ -93,7 +93,7 @@ class Fuzzer:
>>> {'method': 'Translate', 'params': {'x_bias': 0.1, 'y_bias': 0.2}},
>>> {'method': 'Translate', 'params': {'x_bias': 0.1, 'y_bias': 0.2}},
>>> {'method': 'FGSM', 'params': {'eps': 0.1, 'alpha': 0.1}}]
>>> {'method': 'FGSM', 'params': {'eps': 0.1, 'alpha': 0.1}}]
>>> train_images = np.random.rand(32, 1, 32, 32).astype(np.float32)
>>> train_images = np.random.rand(32, 1, 32, 32).astype(np.float32)
>>> model_fuzz_test = Fuzzer(model, train_images, 10
00, 1
0)
>>> model_fuzz_test = Fuzzer(model, train_images, 10
, 100
0)
>>> samples, labels, preds, strategies, report = model_fuzz_test.fuzzing(mutate_config, initial_seeds)
>>> samples, labels, preds, strategies, report = model_fuzz_test.fuzzing(mutate_config, initial_seeds)
"""
"""
...
@@ -141,8 +141,9 @@ class Fuzzer:
...
@@ -141,8 +141,9 @@ class Fuzzer:
Args:
Args:
mutate_config (list): Mutate configs. The format is
mutate_config (list): Mutate configs. The format is
[{'method': 'Blur', 'params': {'auto_param': True}}, {'method': 'Contrast', 'params': {'factor': 2}}].
[{'method': 'Blur', 'params': {'auto_param': True}}, {'method': 'Contrast', 'params': {'factor': 2}}].
The support methods list is in `self._strategies`, and the params of each
The supported methods list is in `self._strategies`, and the params of each method must within the
method must within the range of changeable parameters.
range of changeable parameters. All supported methods are: 'Contrast', 'Brightness', 'Blur',
'Noise', 'Translate', 'Scale', 'Shear', 'Rotate', 'FGSM', 'PGD' and 'MDIIM'.
initial_seeds (numpy.ndarray): Initial seeds used to generate
initial_seeds (numpy.ndarray): Initial seeds used to generate
mutated samples.
mutated samples.
coverage_metric (str): Model coverage metric of neural networks.
coverage_metric (str): Model coverage metric of neural networks.
...
...
mindarmour/fuzzing/model_coverage_metrics.py
浏览文件 @
0b17c39d
...
@@ -56,7 +56,7 @@ class ModelCoverageMetrics:
...
@@ -56,7 +56,7 @@ class ModelCoverageMetrics:
>>> test_images = np.random.random((5000, 128)).astype(np.float32)
>>> test_images = np.random.random((5000, 128)).astype(np.float32)
>>> model = Model(net)
>>> model = Model(net)
>>> model_fuzz_test = ModelCoverageMetrics(model, 10000, 10, train_images)
>>> model_fuzz_test = ModelCoverageMetrics(model, 10000, 10, train_images)
>>> model_fuzz_test.
test_adequacy_coverage_calculat
e(test_images)
>>> model_fuzz_test.
calculate_coverag
e(test_images)
>>> print('KMNC of this test is : %s', model_fuzz_test.get_kmnc())
>>> print('KMNC of this test is : %s', model_fuzz_test.get_kmnc())
>>> print('NBC of this test is : %s', model_fuzz_test.get_nbc())
>>> print('NBC of this test is : %s', model_fuzz_test.get_nbc())
>>> print('SNAC of this test is : %s', model_fuzz_test.get_snac())
>>> print('SNAC of this test is : %s', model_fuzz_test.get_snac())
...
...
mindarmour/utils/logger.py
浏览文件 @
0b17c39d
...
@@ -78,7 +78,11 @@ class LogUtil:
...
@@ -78,7 +78,11 @@ class LogUtil:
def
set_level
(
self
,
level
):
def
set_level
(
self
,
level
):
"""
"""
Set the logging level of this logger, level must be an integer or a
Set the logging level of this logger, level must be an integer or a
string.
string. Supported levels are 'NOTSET'(integer: 0), 'ERROR'(integer: 1-40),
'WARNING'('WARN', integer: 1-30), 'INFO'(integer: 1-20) and 'DEBUG'(integer: 1-10).
For example, if logger.set_level('WARNING') or logger.set_level(21), then
logger.warn() and logger.error() in scripts would be printed while running,
while logger.info() or logger.debug() would not be printed.
Args:
Args:
level (Union[int, str]): Level of logger.
level (Union[int, str]): Level of logger.
...
...
mindarmour/utils/util.py
浏览文件 @
0b17c39d
...
@@ -98,7 +98,7 @@ class GradWrapWithLoss(Cell):
...
@@ -98,7 +98,7 @@ class GradWrapWithLoss(Cell):
Examples:
Examples:
>>> data = Tensor(np.ones([1, 1, 32, 32]).astype(np.float32)*0.01)
>>> data = Tensor(np.ones([1, 1, 32, 32]).astype(np.float32)*0.01)
>>> label = Tensor(np.ones([1, 10]).astype(np.float32))
>>> label
s
= Tensor(np.ones([1, 10]).astype(np.float32))
>>> net = NET()
>>> net = NET()
>>> loss_fn = nn.SoftmaxCrossEntropyWithLogits()
>>> loss_fn = nn.SoftmaxCrossEntropyWithLogits()
>>> loss_net = WithLossCell(net, loss_fn)
>>> loss_net = WithLossCell(net, loss_fn)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录