Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindarmour
提交
ec9d46a7
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看板
提交
ec9d46a7
编写于
5月 29, 2020
作者:
Z
ZhidanLiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix parameter check
上级
f3baf9db
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
8 deletion
+11
-8
mindarmour/diff_privacy/mechanisms/mechanisms.py
mindarmour/diff_privacy/mechanisms/mechanisms.py
+4
-1
mindarmour/utils/_check_param.py
mindarmour/utils/_check_param.py
+3
-3
tests/ut/python/attacks/test_iterative_gradient_method.py
tests/ut/python/attacks/test_iterative_gradient_method.py
+1
-1
tests/ut/python/detectors/test_region_based_detector.py
tests/ut/python/detectors/test_region_based_detector.py
+3
-3
未找到文件。
mindarmour/diff_privacy/mechanisms/mechanisms.py
浏览文件 @
ec9d46a7
...
...
@@ -159,7 +159,10 @@ class AdaGaussianRandom(Mechanisms):
alpha
=
check_param_type
(
'alpha'
,
alpha
,
float
)
self
.
_alpha
=
Tensor
(
np
.
array
(
alpha
,
np
.
float32
))
self
.
_decay_policy
=
check_param_type
(
'decay_policy'
,
decay_policy
,
str
)
if
decay_policy
not
in
[
'Time'
,
'Step'
]:
raise
NameError
(
"The decay_policy must be in ['Time', 'Step'], but "
"get {}"
.
format
(
decay_policy
))
self
.
_decay_policy
=
decay_policy
self
.
_mean
=
0.0
self
.
_sub
=
P
.
Sub
()
self
.
_mul
=
P
.
Mul
()
...
...
mindarmour/utils/_check_param.py
浏览文件 @
ec9d46a7
...
...
@@ -43,7 +43,7 @@ def check_param_type(arg_name, arg_value, valid_type):
valid_type
,
type
(
arg_value
).
__name__
)
LOGGER
.
error
(
TAG
,
msg
)
raise
Valu
eError
(
msg
)
raise
Typ
eError
(
msg
)
return
arg_value
...
...
@@ -54,7 +54,7 @@ def check_param_multi_types(arg_name, arg_value, valid_types):
msg
=
'type of {} must be in {}, but got {}'
\
.
format
(
arg_name
,
valid_types
,
type
(
arg_value
).
__name__
)
LOGGER
.
error
(
TAG
,
msg
)
raise
Valu
eError
(
msg
)
raise
Typ
eError
(
msg
)
return
arg_value
...
...
@@ -157,7 +157,7 @@ def check_numpy_param(arg_name, arg_value):
msg
=
'type of {} must be in (list, tuple, numpy.ndarray)'
.
format
(
arg_name
)
LOGGER
.
error
(
TAG
,
msg
)
raise
Valu
eError
(
msg
)
raise
Typ
eError
(
msg
)
return
arg_value
...
...
tests/ut/python/attacks/test_iterative_gradient_method.py
浏览文件 @
ec9d46a7
...
...
@@ -167,7 +167,7 @@ def test_momentum_diverse_input_iterative_method():
@
pytest
.
mark
.
env_card
@
pytest
.
mark
.
component_mindarmour
def
test_error
():
with
pytest
.
raises
(
Valu
eError
):
with
pytest
.
raises
(
Typ
eError
):
# check_param_multi_types
assert
IterativeGradientMethod
(
Net
(),
bounds
=
None
)
attack
=
IterativeGradientMethod
(
Net
(),
bounds
=
(
0.0
,
1.0
))
...
...
tests/ut/python/detectors/test_region_based_detector.py
浏览文件 @
ec9d46a7
...
...
@@ -100,16 +100,16 @@ def test_value_error():
with
pytest
.
raises
(
ValueError
):
assert
RegionBasedDetector
(
model
,
search_step
=
0
)
with
pytest
.
raises
(
Valu
eError
):
with
pytest
.
raises
(
Typ
eError
):
assert
RegionBasedDetector
(
model
,
sparse
=
'False'
)
detector
=
RegionBasedDetector
(
model
)
with
pytest
.
raises
(
Valu
eError
):
with
pytest
.
raises
(
Typ
eError
):
# radius must not empty
assert
detector
.
detect
(
adv
)
radius
=
detector
.
fit
(
ori
,
labels
)
detector
.
set_radius
(
radius
)
with
pytest
.
raises
(
Valu
eError
):
with
pytest
.
raises
(
Typ
eError
):
# adv type should be in (list, tuple, numpy.ndarray)
assert
detector
.
detect
(
adv
.
tostring
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录