Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindarmour
提交
3e5951cd
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看板
提交
3e5951cd
编写于
8月 19, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 19, 2020
浏览文件
操作
浏览文件
下载
差异文件
!77 Add comment and param-check of Fuzzer
Merge pull request !77 from pkuliuliu/master
上级
6cda5e2e
425cc952
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
266 addition
and
200 deletion
+266
-200
example/mnist_demo/lenet5_mnist_coverage.py
example/mnist_demo/lenet5_mnist_coverage.py
+6
-7
example/mnist_demo/lenet5_mnist_fuzzing.py
example/mnist_demo/lenet5_mnist_fuzzing.py
+3
-3
mindarmour/fuzzing/fuzzing.py
mindarmour/fuzzing/fuzzing.py
+254
-187
tests/ut/python/fuzzing/test_fuzzer.py
tests/ut/python/fuzzing/test_fuzzer.py
+3
-3
未找到文件。
example/mnist_demo/lenet5_mnist_coverage.py
浏览文件 @
3e5951cd
...
@@ -67,7 +67,7 @@ def test_lenet_mnist_coverage():
...
@@ -67,7 +67,7 @@ def test_lenet_mnist_coverage():
test_labels
.
append
(
labels
)
test_labels
.
append
(
labels
)
test_images
=
np
.
concatenate
(
test_images
,
axis
=
0
)
test_images
=
np
.
concatenate
(
test_images
,
axis
=
0
)
test_labels
=
np
.
concatenate
(
test_labels
,
axis
=
0
)
test_labels
=
np
.
concatenate
(
test_labels
,
axis
=
0
)
model_fuzz_test
.
test_adequacy_coverage_calculat
e
(
test_images
)
model_fuzz_test
.
calculate_coverag
e
(
test_images
)
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
model_fuzz_test
.
get_kmnc
())
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
model_fuzz_test
.
get_kmnc
())
LOGGER
.
info
(
TAG
,
'NBC of this test is : %s'
,
model_fuzz_test
.
get_nbc
())
LOGGER
.
info
(
TAG
,
'NBC of this test is : %s'
,
model_fuzz_test
.
get_nbc
())
LOGGER
.
info
(
TAG
,
'SNAC of this test is : %s'
,
model_fuzz_test
.
get_snac
())
LOGGER
.
info
(
TAG
,
'SNAC of this test is : %s'
,
model_fuzz_test
.
get_snac
())
...
@@ -76,14 +76,13 @@ def test_lenet_mnist_coverage():
...
@@ -76,14 +76,13 @@ def test_lenet_mnist_coverage():
loss
=
SoftmaxCrossEntropyWithLogits
(
is_grad
=
False
,
sparse
=
True
)
loss
=
SoftmaxCrossEntropyWithLogits
(
is_grad
=
False
,
sparse
=
True
)
attack
=
FastGradientSignMethod
(
net
,
eps
=
0.3
,
loss_fn
=
loss
)
attack
=
FastGradientSignMethod
(
net
,
eps
=
0.3
,
loss_fn
=
loss
)
adv_data
=
attack
.
batch_generate
(
test_images
,
test_labels
,
batch_size
=
32
)
adv_data
=
attack
.
batch_generate
(
test_images
,
test_labels
,
batch_size
=
32
)
model_fuzz_test
.
test_adequacy_coverage_calculate
(
adv_data
,
model_fuzz_test
.
calculate_coverage
(
adv_data
,
bias_coefficient
=
0.5
)
bias_coefficient
=
0.5
)
LOGGER
.
info
(
TAG
,
'KMNC of this adv data is : %s'
,
model_fuzz_test
.
get_kmnc
())
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
model_fuzz_test
.
get_kmnc
())
LOGGER
.
info
(
TAG
,
'NBC of this adv data is : %s'
,
model_fuzz_test
.
get_nbc
())
LOGGER
.
info
(
TAG
,
'NBC of this test is : %s'
,
model_fuzz_test
.
get_nbc
())
LOGGER
.
info
(
TAG
,
'SNAC of this adv data is : %s'
,
model_fuzz_test
.
get_snac
())
LOGGER
.
info
(
TAG
,
'SNAC of this test is : %s'
,
model_fuzz_test
.
get_snac
())
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# device_target can be "CPU", "GPU" or "Ascend"
# device_target can be "CPU", "GPU" or "Ascend"
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"
CPU
"
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"
Ascend
"
)
test_lenet_mnist_coverage
()
test_lenet_mnist_coverage
()
example/mnist_demo/lenet5_mnist_fuzzing.py
浏览文件 @
3e5951cd
...
@@ -87,9 +87,9 @@ def test_lenet_mnist_fuzzing():
...
@@ -87,9 +87,9 @@ def test_lenet_mnist_fuzzing():
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
model_coverage_test
.
get_kmnc
())
model_coverage_test
.
get_kmnc
())
model_fuzz_test
=
Fuzzer
(
model
,
train_images
,
10
00
,
1
0
)
model_fuzz_test
=
Fuzzer
(
model
,
train_images
,
10
,
100
0
)
_
,
_
,
_
,
_
,
metrics
=
model_fuzz_test
.
fuzzing
(
mutate_config
,
initial_seeds
,
_
,
_
,
_
,
_
,
metrics
=
model_fuzz_test
.
fuzzing
(
mutate_config
,
initial_seeds
,
eval_metric
=
True
)
eval_metric
s
=
'auto'
)
if
metrics
:
if
metrics
:
for
key
in
metrics
:
for
key
in
metrics
:
LOGGER
.
info
(
TAG
,
key
+
': %s'
,
metrics
[
key
])
LOGGER
.
info
(
TAG
,
key
+
': %s'
,
metrics
[
key
])
...
@@ -97,5 +97,5 @@ def test_lenet_mnist_fuzzing():
...
@@ -97,5 +97,5 @@ def test_lenet_mnist_fuzzing():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# device_target can be "CPU", "GPU" or "Ascend"
# device_target can be "CPU", "GPU" or "Ascend"
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"
CPU
"
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"
Ascend
"
)
test_lenet_mnist_fuzzing
()
test_lenet_mnist_fuzzing
()
mindarmour/fuzzing/fuzzing.py
浏览文件 @
3e5951cd
此差异已折叠。
点击以展开。
tests/ut/python/fuzzing/test_fuzzer.py
浏览文件 @
3e5951cd
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""
"""
Model-fuzz
coverage
test.
Model-fuzz
er
test.
"""
"""
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
...
@@ -121,7 +121,7 @@ def test_fuzzing_ascend():
...
@@ -121,7 +121,7 @@ def test_fuzzing_ascend():
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
model_coverage_test
.
get_kmnc
())
model_coverage_test
.
get_kmnc
())
model_fuzz_test
=
Fuzzer
(
model
,
train_images
,
10
00
,
1
0
)
model_fuzz_test
=
Fuzzer
(
model
,
train_images
,
10
,
100
0
)
_
,
_
,
_
,
_
,
metrics
=
model_fuzz_test
.
fuzzing
(
mutate_config
,
initial_seeds
)
_
,
_
,
_
,
_
,
metrics
=
model_fuzz_test
.
fuzzing
(
mutate_config
,
initial_seeds
)
print
(
metrics
)
print
(
metrics
)
...
@@ -167,6 +167,6 @@ def test_fuzzing_cpu():
...
@@ -167,6 +167,6 @@ def test_fuzzing_cpu():
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
LOGGER
.
info
(
TAG
,
'KMNC of this test is : %s'
,
model_coverage_test
.
get_kmnc
())
model_coverage_test
.
get_kmnc
())
model_fuzz_test
=
Fuzzer
(
model
,
train_images
,
10
00
,
1
0
)
model_fuzz_test
=
Fuzzer
(
model
,
train_images
,
10
,
100
0
)
_
,
_
,
_
,
_
,
metrics
=
model_fuzz_test
.
fuzzing
(
mutate_config
,
initial_seeds
)
_
,
_
,
_
,
_
,
metrics
=
model_fuzz_test
.
fuzzing
(
mutate_config
,
initial_seeds
)
print
(
metrics
)
print
(
metrics
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录