Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
c006a609
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c006a609
编写于
3月 25, 2022
作者:
D
duanboqiang
提交者:
GitHub
3月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix lars optitmizer bug (#40892)
* fix lars optitmizer bug * Update optimizer.py
上级
9ab3c76b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
8 addition
and
19 deletion
+8
-19
paddle/fluid/operators/optimizers/lars_momentum_op.cu
paddle/fluid/operators/optimizers/lars_momentum_op.cu
+1
-1
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+7
-18
未找到文件。
paddle/fluid/operators/optimizers/lars_momentum_op.cu
浏览文件 @
c006a609
...
@@ -204,7 +204,7 @@ __forceinline__ __device__ void MomentumUpdate(
...
@@ -204,7 +204,7 @@ __forceinline__ __device__ void MomentumUpdate(
const
bool
is_amp
)
{
const
bool
is_amp
)
{
const
MT
lr
=
learning_rate
[
0
];
const
MT
lr
=
learning_rate
[
0
];
MT
local_lr
=
lr
;
MT
local_lr
=
lr
;
if
(
lars_weight_decay
>
static_cast
<
MT
>
(
0
))
{
if
(
param_norm
>
static_cast
<
MT
>
(
0
)
&&
grad_norm
>
static_cast
<
MT
>
(
0
))
{
local_lr
=
lr
*
lars_coeff
*
param_norm
/
local_lr
=
lr
*
lars_coeff
*
param_norm
/
(
fma
(
lars_weight_decay
,
param_norm
,
grad_norm
)
+
epsilon
);
(
fma
(
lars_weight_decay
,
param_norm
,
grad_norm
)
+
epsilon
);
}
}
...
...
python/paddle/fluid/optimizer.py
浏览文件 @
c006a609
...
@@ -2156,27 +2156,16 @@ class LarsMomentumOptimizer(Optimizer):
...
@@ -2156,27 +2156,16 @@ class LarsMomentumOptimizer(Optimizer):
outputs
[
"MasterParamOut"
]
=
master_weight
outputs
[
"MasterParamOut"
]
=
master_weight
if
framework
.
_non_static_mode
():
if
framework
.
_non_static_mode
():
if
_lars_weight_decay
!=
0.0
:
tmp
,
tmp2
=
_C_ops
.
lars_momentum
(
tmp
,
tmp2
=
_C_ops
.
lars_momentum
(
[
param_and_grad
[
0
]],
[
param_and_grad
[
1
]],
[
velocity_acc
],
[
lr
],
[
param_and_grad
[
0
]],
[
param_and_grad
[
1
]],
[
velocity_acc
],
[
param_and_grad
[
0
]],
[
velocity_acc
],
"mu"
,
self
.
_momentum
,
[
lr
],
[
param_and_grad
[
0
]],
[
velocity_acc
],
"mu"
,
"lars_coeff"
,
self
.
_lars_coeff
,
"lars_weight_decay"
,
self
.
_momentum
,
"lars_coeff"
,
self
.
_lars_coeff
,
[
_lars_weight_decay
],
"multi_precision"
,
find_master
,
"epsilon"
,
"lars_weight_decay"
,
[
_lars_weight_decay
],
self
.
_epsilon
,
"rescale_grad"
,
self
.
_rescale_grad
)
"multi_precision"
,
find_master
,
"epsilon"
,
self
.
_epsilon
,
"rescale_grad"
,
self
.
_rescale_grad
)
else
:
_C_ops
.
momentum
(
param_and_grad
[
0
],
param_and_grad
[
1
],
velocity_acc
,
lr
,
master_weight
,
param_and_grad
[
0
],
velocity_acc
,
master_weight
,
"mu"
,
self
.
_momentum
,
"lars_coeff"
,
self
.
_lars_coeff
,
"lars_weight_decay"
,
[
_lars_weight_decay
],
"multi_precision"
,
find_master
,
"epsilon"
,
self
.
_epsilon
,
"rescale_grad"
,
self
.
_rescale_grad
)
else
:
else
:
# create the momentum optimize op
# create the momentum optimize op
momentum_op
=
block
.
append_op
(
momentum_op
=
block
.
append_op
(
type
=
self
.
type
if
_lars_weight_decay
!=
0.0
else
'momentum'
,
type
=
self
.
type
,
inputs
=
inputs
,
inputs
=
inputs
,
outputs
=
outputs
,
outputs
=
outputs
,
attrs
=
attrs
,
attrs
=
attrs
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录