Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
docs
提交
9fdc2092
D
docs
项目概览
MindSpore
/
docs
通知
4
Star
2
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9fdc2092
编写于
5月 30, 2020
作者:
Z
ZhidanLiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update tutorial of differential privacy
上级
59ae1d6e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
4 deletion
+4
-4
tutorials/source_zh_cn/advanced_use/differential_privacy.md
tutorials/source_zh_cn/advanced_use/differential_privacy.md
+4
-4
未找到文件。
tutorials/source_zh_cn/advanced_use/differential_privacy.md
浏览文件 @
9fdc2092
...
@@ -57,6 +57,7 @@ from mindarmour.utils.logger import LogUtil
...
@@ -57,6 +57,7 @@ from mindarmour.utils.logger import LogUtil
from
lenet5_net
import
LeNet5
from
lenet5_net
import
LeNet5
from
lenet5_config
import
mnist_cfg
as
cfg
from
lenet5_config
import
mnist_cfg
as
cfg
LOGGER
=
LogUtil
.
get_instances
()
LOGGER
.
set_level
(
'INFO'
)
LOGGER
.
set_level
(
'INFO'
)
TAG
=
'Lenet5_train'
TAG
=
'Lenet5_train'
```
```
...
@@ -234,7 +235,7 @@ ds_train = generate_mnist_dataset(os.path.join(args.data_path, "train"),
...
@@ -234,7 +235,7 @@ ds_train = generate_mnist_dataset(os.path.join(args.data_path, "train"),
if
args
.
micro_batches
and
cfg
.
batch_size
%
args
.
micro_batches
!=
0
:
if
args
.
micro_batches
and
cfg
.
batch_size
%
args
.
micro_batches
!=
0
:
raise
ValueError
(
"Number of micro_batches should divide evenly batch_size"
)
raise
ValueError
(
"Number of micro_batches should divide evenly batch_size"
)
gaussian_mech
=
DPOptimizerClassFactory
(
args
.
micro_batches
)
gaussian_mech
=
DPOptimizerClassFactory
(
args
.
micro_batches
)
gaussian_mech
.
set_mechanisms
(
'Gaussian'
,
gaussian_mech
.
set_mechanisms
(
'
Ada
Gaussian'
,
norm_bound
=
args
.
l2_norm_bound
,
norm_bound
=
args
.
l2_norm_bound
,
initial_noise_multiplier
=
args
.
initial_noise_multiplier
)
initial_noise_multiplier
=
args
.
initial_noise_multiplier
)
net_opt
=
gaussian_mech
.
create
(
'Momentum'
)(
params
=
network
.
trainable_params
(),
net_opt
=
gaussian_mech
.
create
(
'Momentum'
)(
params
=
network
.
trainable_params
(),
...
@@ -289,14 +290,13 @@ ds_train = generate_mnist_dataset(os.path.join(args.data_path, "train"),
...
@@ -289,14 +290,13 @@ ds_train = generate_mnist_dataset(os.path.join(args.data_path, "train"),
5.
结果展示。
5.
结果展示。
不加差分隐私的LeNet模型精度稳定在99%,加了自适应差分隐私AdaDP的LeNet模型收敛,精度稳定在96%,加了非自适应差分隐私DP[3]的LeNet模型收敛,精度稳定在94%左右。
不加差分隐私的LeNet模型精度稳定在99%,加了自适应差分隐私AdaDP的LeNet模型收敛,精度稳定在91%。
```
```
============== Starting Training ==============
============== Starting Training ==============
...
...
============== Starting Testing ==============
============== Starting Testing ==============
...
...
============== Accuracy: 0.9
091
==============
============== Accuracy: 0.9
115
==============
```
```
### 引用
### 引用
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录