Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
768f9242
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看板
提交
768f9242
编写于
12月 04, 2019
作者:
W
WangXi
提交者:
gongweibao
12月 04, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix dgc clip & rampup step, test=develop (#21491)
上级
9144ae42
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
8 addition
and
5 deletion
+8
-5
paddle/fluid/operators/dgc_op.h
paddle/fluid/operators/dgc_op.h
+4
-3
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+2
-2
python/paddle/fluid/tests/unittests/test_dgc_optimizer.py
python/paddle/fluid/tests/unittests/test_dgc_optimizer.py
+2
-0
未找到文件。
paddle/fluid/operators/dgc_op.h
浏览文件 @
768f9242
...
@@ -28,7 +28,7 @@ inline float get_period_sparcity(const std::vector<float>& sparsity,
...
@@ -28,7 +28,7 @@ inline float get_period_sparcity(const std::vector<float>& sparsity,
size_t
idx
=
static_cast
<
int
>
(
cur_step
*
sparsity
.
size
()
/
rampup_steps
);
size_t
idx
=
static_cast
<
int
>
(
cur_step
*
sparsity
.
size
()
/
rampup_steps
);
if
(
idx
>=
sparsity
.
size
())
{
if
(
idx
>=
sparsity
.
size
())
{
return
0.999
;
idx
=
sparsity
.
size
()
-
1
;
}
}
PADDLE_ENFORCE_LT
(
idx
,
sparsity
.
size
());
PADDLE_ENFORCE_LT
(
idx
,
sparsity
.
size
());
...
@@ -102,7 +102,8 @@ class DGCOpKernel : public framework::OpKernel<T> {
...
@@ -102,7 +102,8 @@ class DGCOpKernel : public framework::OpKernel<T> {
}
}
float
ratio
=
float
ratio
=
1
-
get_period_sparcity
(
sparsity
,
static_cast
<
float
>
(
*
current_step
),
1
-
get_period_sparcity
(
sparsity
,
static_cast
<
float
>
(
*
current_step
-
rampup_begin_step
),
rampup_step
);
rampup_step
);
PADDLE_ENFORCE_GE
(
ratio
,
0.0
);
PADDLE_ENFORCE_GE
(
ratio
,
0.0
);
PADDLE_ENFORCE_LT
(
ratio
,
1.0
);
PADDLE_ENFORCE_LT
(
ratio
,
1.0
);
...
...
python/paddle/fluid/optimizer.py
浏览文件 @
768f9242
...
@@ -949,6 +949,7 @@ class DGCMomentumOptimizer(Optimizer):
...
@@ -949,6 +949,7 @@ class DGCMomentumOptimizer(Optimizer):
self
.
_momentum
=
momentum
self
.
_momentum
=
momentum
self
.
_use_nesterov
=
bool
(
use_nesterov
)
self
.
_use_nesterov
=
bool
(
use_nesterov
)
assert
rampup_begin_step
>=
0
,
"rampup_begin_step must >= 0"
self
.
_rampup_begin_step
=
rampup_begin_step
self
.
_rampup_begin_step
=
rampup_begin_step
self
.
_rampup_step
=
rampup_step
self
.
_rampup_step
=
rampup_step
self
.
_sparsity
=
sparsity
self
.
_sparsity
=
sparsity
...
@@ -965,8 +966,7 @@ class DGCMomentumOptimizer(Optimizer):
...
@@ -965,8 +966,7 @@ class DGCMomentumOptimizer(Optimizer):
self
.
_local_grad_clip_norm
=
local_grad_clip_norm
self
.
_local_grad_clip_norm
=
local_grad_clip_norm
self
.
_num_trainers
=
num_trainers
self
.
_num_trainers
=
num_trainers
self
.
_clip_norm
=
local_grad_clip_norm
/
(
num_trainers
*
self
.
_clip_norm
=
local_grad_clip_norm
*
(
num_trainers
**-
0.5
)
num_trainers
)
self
.
_get_dgc_regularization_param
()
self
.
_get_dgc_regularization_param
()
...
...
python/paddle/fluid/tests/unittests/test_dgc_optimizer.py
浏览文件 @
768f9242
...
@@ -67,6 +67,8 @@ class TestDGCMomentumOptimizer(unittest.TestCase):
...
@@ -67,6 +67,8 @@ class TestDGCMomentumOptimizer(unittest.TestCase):
learning_rate
=
learning_rate
,
learning_rate
=
learning_rate
,
momentum
=
0.2
,
momentum
=
0.2
,
rampup_begin_step
=
0
,
rampup_begin_step
=
0
,
local_grad_clip_norm
=
1.0
,
num_trainers
=
2
,
regularization
=
regularization
)
regularization
=
regularization
)
mean_out
=
block
.
create_var
(
mean_out
=
block
.
create_var
(
dtype
=
"float32"
,
shape
=
[
1
],
lod_level
=
0
,
name
=
"mean.out"
)
dtype
=
"float32"
,
shape
=
[
1
],
lod_level
=
0
,
name
=
"mean.out"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录