Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
fd3adf58
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fd3adf58
编写于
3月 13, 2019
作者:
D
dongdaxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add distributed optimizer factory
上级
f6128777
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
12 deletion
+14
-12
python/paddle/fluid/incubate/fleet/parameter_server/optimizer_factory.py
...luid/incubate/fleet/parameter_server/optimizer_factory.py
+14
-12
未找到文件。
python/paddle/fluid/incubate/fleet/parameter_server/optimizer_factory.py
浏览文件 @
fd3adf58
...
...
@@ -14,18 +14,21 @@
__all__
=
[
"DistributedAdam"
]
import
ps_pb2
as
pslib
import
paddle.fluid
as
fluid
from
paddle.fluid.distribute_lookup_table
import
find_distributed_lookup_table
from
paddle.fluid.distribute_lookup_table
import
find_distributed_lookup_table_inputs
from
paddle.fluid.distribute_lookup_table
import
find_distributed_lookup_table_outputs
from
google.protobuf
import
text_format
from
.node
import
DownpourWorker
,
DownpourServer
class
DistributedOptimizerImplBase
(
object
):
def
__init__
(
self
):
pass
def
__init__
(
self
,
optimizer
):
self
.
optimizer_
=
optimizer
self
.
learning_rate_
=
optimizer
.
_learning_rate
self
.
regularization_
=
optimizer
.
regularization
def
minimize
(
self
,
optimizer
,
losses
,
startup_program
=
None
,
parameter_list
=
None
,
...
...
@@ -34,11 +37,11 @@ class DistributedOptimizerImplBase(object):
class
DistributedAdam
(
DistributedOptimizerImplBase
):
def
__init__
(
self
):
def
__init__
(
self
,
optimizer
):
# todo(guru4elephant): add more optimizers here as argument
# todo(guru4elephant): make learning_rate as a variable
s
elf
.
learning_rate_
=
learning_rate
self
.
window_
=
window
s
uper
(
DistributedAdam
,
self
).
__init__
(
optimizer
)
self
.
window_
=
1
self
.
type
=
"downpour"
self
.
data_norm_name
=
[
".batch_size"
,
".batch_square_sum"
,
".batch_sum"
,
...
...
@@ -46,8 +49,7 @@ class DistributedAdam(DistributedOptimizerImplBase):
]
def
minimize
(
self
,
optimizer
,
loss
,
losses
,
startup_program
=
None
,
parameter_list
=
None
,
no_grad_set
=
None
):
...
...
@@ -64,8 +66,8 @@ class DistributedAdam(DistributedOptimizerImplBase):
Returns:
[optimize_ops, grads_and_weights]
"""
if
not
isinstance
(
loss
,
list
):
loss
=
[
los
s
]
if
not
isinstance
(
loss
es
,
list
):
loss
es
=
[
losse
s
]
table_name
=
find_distributed_lookup_table
(
losses
[
0
].
block
.
program
)
prefetch_slots
=
find_distributed_lookup_table_inputs
(
...
...
@@ -92,8 +94,8 @@ class DistributedAdam(DistributedOptimizerImplBase):
program_config
.
pull_sparse_table_id
.
extend
([
sparse_table_index
])
program_config
.
push_sparse_table_id
.
extend
([
sparse_table_index
])
params_grads
=
sorted
(
append_backward
(
losses
[
loss_index
],
parameter_list
,
no_grad_set
),
fluid
.
backward
.
append_backward
(
losses
[
loss_index
]
,
parameter_list
,
no_grad_set
),
key
=
lambda
x
:
x
[
0
].
name
)
param_grads_list
.
append
(
params_grads
)
params
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录