Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
b213bb1a
P
PaddleFL
项目概览
PaddlePaddle
/
PaddleFL
通知
35
Star
5
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
4
Wiki
3
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleFL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
3
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b213bb1a
编写于
10月 10, 2019
作者:
F
frankwhzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify dpsgd_strategy optimizer
上级
08672bda
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
40 addition
and
3 deletion
+40
-3
paddle_fl/core/strategy/fl_strategy_base.py
paddle_fl/core/strategy/fl_strategy_base.py
+35
-1
paddle_fl/examples/dpsgd_demo/fl_master.py
paddle_fl/examples/dpsgd_demo/fl_master.py
+5
-2
未找到文件。
paddle_fl/core/strategy/fl_strategy_base.py
浏览文件 @
b213bb1a
...
@@ -110,10 +110,44 @@ class DPSGDStrategy(FLStrategyBase):
...
@@ -110,10 +110,44 @@ class DPSGDStrategy(FLStrategyBase):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
DPSGDStrategy
,
self
).
__init__
()
super
(
DPSGDStrategy
,
self
).
__init__
()
@
property
def
learning_rate
(
self
):
return
self
.
_learning_rate
@
learning_rate
.
setter
def
learning_rate
(
self
,
s
):
self
.
_learning_rate
=
s
@
property
def
clip
(
self
):
return
self
.
_clip
@
clip
.
setter
def
clip
(
self
,
s
):
self
.
_clip
=
s
@
property
def
batch_size
(
self
):
return
self
.
_batch_size
@
batch_size
.
setter
def
batch_size
(
self
,
s
):
self
.
_batch_size
=
s
@
property
def
sigma
(
self
):
return
self
.
_sigma
@
sigma
.
setter
def
sigma
(
self
,
s
):
self
.
_sigma
=
s
def
minimize
(
self
,
optimizer
=
None
,
losses
=
[]):
def
minimize
(
self
,
optimizer
=
None
,
losses
=
[]):
"""
"""
D
o nothing in DPSGDStrategy in minimize function
D
efine Dpsgd optimizeer
"""
"""
optimizer
=
fluid
.
optimizer
.
Dpsgd
(
self
.
_learning_rate
,
clip
=
self
.
_clip
,
batch_size
=
self
.
_batch_size
,
sigma
=
self
.
_sigma
)
print
(
str
(
optimizer
))
optimizer
.
minimize
(
losses
[
0
])
optimizer
.
minimize
(
losses
[
0
])
def
_build_trainer_program_for_job
(
def
_build_trainer_program_for_job
(
...
...
paddle_fl/examples/dpsgd_demo/fl_master.py
浏览文件 @
b213bb1a
...
@@ -28,8 +28,7 @@ CLIP = 4.0
...
@@ -28,8 +28,7 @@ CLIP = 4.0
batch_size
=
64
batch_size
=
64
job_generator
=
JobGenerator
()
job_generator
=
JobGenerator
()
optimizer
=
fluid
.
optimizer
.
Dpsgd
(
0.1
,
clip
=
CLIP
,
batch_size
=
float
(
batch_size
),
sigma
=
CLIP
*
SIGMA
)
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.1
)
# optimizer = fluid.optimizer.SGD(learning_rate=0.1)
job_generator
.
set_optimizer
(
optimizer
)
job_generator
.
set_optimizer
(
optimizer
)
job_generator
.
set_losses
([
model
.
loss
])
job_generator
.
set_losses
([
model
.
loss
])
job_generator
.
set_startup_program
(
model
.
startup_program
)
job_generator
.
set_startup_program
(
model
.
startup_program
)
...
@@ -40,6 +39,10 @@ build_strategy = FLStrategyFactory()
...
@@ -40,6 +39,10 @@ build_strategy = FLStrategyFactory()
build_strategy
.
dpsgd
=
True
build_strategy
.
dpsgd
=
True
build_strategy
.
inner_step
=
1
build_strategy
.
inner_step
=
1
strategy
=
build_strategy
.
create_fl_strategy
()
strategy
=
build_strategy
.
create_fl_strategy
()
strategy
.
learning_rate
=
0.1
strategy
.
clip
=
CLIP
strategy
.
batch_size
=
float
(
batch_size
)
strategy
.
sigma
=
CLIP
*
SIGMA
# endpoints will be collected through the cluster
# endpoints will be collected through the cluster
# in this example, we suppose endpoints have been collected
# in this example, we suppose endpoints have been collected
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录