Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
5903151f
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5903151f
编写于
9月 27, 2020
作者:
C
Chen Weihang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move apply in minimize
上级
28dac4ec
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
18 addition
and
18 deletion
+18
-18
python/paddle/fluid/dygraph/varbase_patch_methods.py
python/paddle/fluid/dygraph/varbase_patch_methods.py
+1
-1
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+8
-6
python/paddle/optimizer/adamw.py
python/paddle/optimizer/adamw.py
+1
-5
python/paddle/optimizer/optimizer.py
python/paddle/optimizer/optimizer.py
+8
-6
未找到文件。
python/paddle/fluid/dygraph/varbase_patch_methods.py
浏览文件 @
5903151f
...
@@ -19,7 +19,7 @@ import paddle
...
@@ -19,7 +19,7 @@ import paddle
from
..
import
framework
from
..
import
framework
from
..
import
core
from
..
import
core
from
..framework
import
Variable
,
Parameter
,
ParamBase
from
..framework
import
Variable
,
Parameter
,
ParamBase
from
.base
import
switch_to_static_graph
,
to_variable
from
.base
import
switch_to_static_graph
from
.math_op_patch
import
monkey_patch_math_varbase
from
.math_op_patch
import
monkey_patch_math_varbase
from
.parallel
import
scale_loss
from
.parallel
import
scale_loss
...
...
python/paddle/fluid/optimizer.py
浏览文件 @
5903151f
...
@@ -22,7 +22,7 @@ from collections import defaultdict
...
@@ -22,7 +22,7 @@ from collections import defaultdict
import
paddle
import
paddle
from
paddle.fluid.distribute_lookup_table
import
find_distributed_lookup_table
from
paddle.fluid.distribute_lookup_table
import
find_distributed_lookup_table
from
paddle.fluid.framework
import
Program
,
Variable
,
name_scope
,
default_main_program
,
default_startup_program
,
device_guard
from
paddle.fluid.framework
import
Program
,
Variable
,
name_scope
,
default_main_program
,
default_startup_program
,
device_guard
from
paddle.fluid.dygraph.parallel
import
scale_loss
,
apply_collective_grads
from
paddle.fluid.dygraph.parallel
import
apply_collective_grads
from
.
import
framework
from
.
import
framework
from
.
import
layers
from
.
import
layers
...
@@ -772,8 +772,14 @@ class Optimizer(object):
...
@@ -772,8 +772,14 @@ class Optimizer(object):
self
.
_dtype
=
loss
.
dtype
self
.
_dtype
=
loss
.
dtype
if
framework
.
in_dygraph_mode
():
if
framework
.
in_dygraph_mode
():
parameter_list
=
parameter_list
if
parameter_list
\
else
self
.
_parameter_list
if
paddle
.
distributed
.
get_world_size
()
>
1
:
apply_collective_grads
(
parameter_list
)
params_grads
=
[]
params_grads
=
[]
for
param
in
self
.
_
parameter_list
:
for
param
in
parameter_list
:
if
not
param
.
trainable
:
if
not
param
.
trainable
:
continue
continue
if
param
.
_grad_ivar
()
is
not
None
:
if
param
.
_grad_ivar
()
is
not
None
:
...
@@ -941,10 +947,6 @@ class Optimizer(object):
...
@@ -941,10 +947,6 @@ class Optimizer(object):
parameter_list
=
parameter_list
if
parameter_list
\
parameter_list
=
parameter_list
if
parameter_list
\
else
self
.
_parameter_list
else
self
.
_parameter_list
if
paddle
.
distributed
.
get_world_size
()
>
1
:
loss
=
scale_loss
(
loss
)
apply_collective_grads
(
parameter_list
)
params_grads
=
self
.
backward
(
params_grads
=
self
.
backward
(
loss
,
loss
,
startup_program
=
startup_program
,
startup_program
=
startup_program
,
...
...
python/paddle/optimizer/adamw.py
浏览文件 @
5903151f
...
@@ -16,7 +16,7 @@ from .optimizer import Optimizer
...
@@ -16,7 +16,7 @@ from .optimizer import Optimizer
from
.adam
import
Adam
from
.adam
import
Adam
from
..fluid
import
framework
from
..fluid
import
framework
import
paddle
import
paddle
from
paddle.fluid.dygraph.parallel
import
scale_loss
,
apply_collective_grads
from
paddle.fluid.dygraph.parallel
import
apply_collective_grads
__all__
=
[
'AdamW'
]
__all__
=
[
'AdamW'
]
...
@@ -189,10 +189,6 @@ class AdamW(Adam):
...
@@ -189,10 +189,6 @@ class AdamW(Adam):
parameters
=
parameters
if
parameters
\
parameters
=
parameters
if
parameters
\
else
self
.
_parameter_list
else
self
.
_parameter_list
if
paddle
.
distributed
.
get_world_size
()
>
1
:
loss
=
scale_loss
(
loss
)
apply_collective_grads
(
parameter_list
)
params_grads
=
self
.
backward
(
params_grads
=
self
.
backward
(
loss
=
loss
,
loss
=
loss
,
startup_program
=
startup_program
,
startup_program
=
startup_program
,
...
...
python/paddle/optimizer/optimizer.py
浏览文件 @
5903151f
...
@@ -22,7 +22,7 @@ from collections import defaultdict
...
@@ -22,7 +22,7 @@ from collections import defaultdict
import
paddle
import
paddle
from
paddle.fluid.distribute_lookup_table
import
find_distributed_lookup_table
from
paddle.fluid.distribute_lookup_table
import
find_distributed_lookup_table
from
paddle.fluid.framework
import
Program
,
Variable
,
name_scope
,
default_main_program
,
default_startup_program
,
device_guard
from
paddle.fluid.framework
import
Program
,
Variable
,
name_scope
,
default_main_program
,
default_startup_program
,
device_guard
from
paddle.fluid.dygraph.parallel
import
scale_loss
,
apply_collective_grads
from
paddle.fluid.dygraph.parallel
import
apply_collective_grads
from
..fluid
import
framework
from
..fluid
import
framework
from
..fluid
import
layers
from
..fluid
import
layers
...
@@ -676,8 +676,14 @@ class Optimizer(object):
...
@@ -676,8 +676,14 @@ class Optimizer(object):
self
.
_dtype
=
loss
.
dtype
self
.
_dtype
=
loss
.
dtype
if
framework
.
in_dygraph_mode
():
if
framework
.
in_dygraph_mode
():
parameter_list
=
parameters
if
parameters
\
else
self
.
_parameter_list
if
paddle
.
distributed
.
get_world_size
()
>
1
:
apply_collective_grads
(
parameter_list
)
params_grads
=
[]
params_grads
=
[]
for
param
in
self
.
_
parameter_list
:
for
param
in
parameter_list
:
if
not
param
.
trainable
:
if
not
param
.
trainable
:
continue
continue
if
param
.
_grad_ivar
()
is
not
None
:
if
param
.
_grad_ivar
()
is
not
None
:
...
@@ -873,10 +879,6 @@ class Optimizer(object):
...
@@ -873,10 +879,6 @@ class Optimizer(object):
parameter_list
=
parameters
if
parameters
\
parameter_list
=
parameters
if
parameters
\
else
self
.
_parameter_list
else
self
.
_parameter_list
if
paddle
.
distributed
.
get_world_size
()
>
1
:
loss
=
scale_loss
(
loss
)
apply_collective_grads
(
parameter_list
)
params_grads
=
self
.
backward
(
params_grads
=
self
.
backward
(
loss
,
loss
,
startup_program
=
startup_program
,
startup_program
=
startup_program
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录