Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
AutoDL
提交
b3d3f7ce
A
AutoDL
项目概览
PaddlePaddle
/
AutoDL
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AutoDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b3d3f7ce
编写于
1月 07, 2020
作者:
Z
Zhang Ting
提交者:
wangguanzhong
1月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove init_on_cpu because it does not take effect, test=develop (#18)
上级
5447bcf7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
20 deletion
+14
-20
AutoDL Design/inception_train/nn.py
AutoDL Design/inception_train/nn.py
+1
-3
LRC/learning_rate.py
LRC/learning_rate.py
+3
-5
NAS-Models/train_cifar.py
NAS-Models/train_cifar.py
+10
-12
未找到文件。
AutoDL Design/inception_train/nn.py
浏览文件 @
b3d3f7ce
...
...
@@ -27,7 +27,6 @@ import paddle.fluid.layers.ops as ops
import
paddle.fluid
as
fluid
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
import
math
from
paddle.fluid.initializer
import
init_on_cpu
from
models
import
inception
from
absl
import
flags
...
...
@@ -66,8 +65,7 @@ class CIFARModel(object):
Applies cosine decay to the learning rate.
"""
global_step
=
_decay_step_counter
()
with
init_on_cpu
():
frac
=
(
1
+
ops
.
cos
(
global_step
/
max_step
*
math
.
pi
))
/
2
frac
=
(
1
+
ops
.
cos
(
global_step
/
max_step
*
math
.
pi
))
/
2
return
FLAGS
.
lr_min
+
(
FLAGS
.
lr_max
-
FLAGS
.
lr_min
)
*
frac
self
.
lr_strategy
=
cosine_decay
...
...
LRC/learning_rate.py
浏览文件 @
b3d3f7ce
...
...
@@ -27,7 +27,6 @@ import paddle.fluid as fluid
import
paddle.fluid.layers.ops
as
ops
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
import
math
from
paddle.fluid.initializer
import
init_on_cpu
def
cosine_decay
(
learning_rate
,
num_epoch
,
steps_one_epoch
):
...
...
@@ -36,10 +35,9 @@ def cosine_decay(learning_rate, num_epoch, steps_one_epoch):
"""
global_step
=
_decay_step_counter
()
with
init_on_cpu
():
decayed_lr
=
learning_rate
*
\
(
ops
.
cos
(
fluid
.
layers
.
floor
(
global_step
/
steps_one_epoch
)
\
*
math
.
pi
/
num_epoch
)
+
1
)
/
2
decayed_lr
=
learning_rate
*
\
(
ops
.
cos
(
fluid
.
layers
.
floor
(
global_step
/
steps_one_epoch
)
\
*
math
.
pi
/
num_epoch
)
+
1
)
/
2
return
decayed_lr
...
...
NAS-Models/train_cifar.py
浏览文件 @
b3d3f7ce
...
...
@@ -69,7 +69,6 @@ def cosine_decay_with_warmup(learning_rate, step_each_epoch, epochs=120):
decrease lr for every mini-batch and start with warmup.
"""
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
from
paddle.fluid.initializer
import
init_on_cpu
global_step
=
_decay_step_counter
()
lr
=
fluid
.
layers
.
tensor
.
create_global_var
(
shape
=
[
1
],
...
...
@@ -81,17 +80,16 @@ def cosine_decay_with_warmup(learning_rate, step_each_epoch, epochs=120):
warmup_epoch
=
fluid
.
layers
.
fill_constant
(
shape
=
[
1
],
dtype
=
'float32'
,
value
=
float
(
5
),
force_cpu
=
True
)
with
init_on_cpu
():
epoch
=
ops
.
floor
(
global_step
/
step_each_epoch
)
with
fluid
.
layers
.
control_flow
.
Switch
()
as
switch
:
with
switch
.
case
(
epoch
<
warmup_epoch
):
decayed_lr
=
learning_rate
*
(
global_step
/
(
step_each_epoch
*
warmup_epoch
))
fluid
.
layers
.
tensor
.
assign
(
input
=
decayed_lr
,
output
=
lr
)
with
switch
.
default
():
decayed_lr
=
learning_rate
*
\
(
ops
.
cos
((
global_step
-
warmup_epoch
*
step_each_epoch
)
*
(
math
.
pi
/
(
epochs
*
step_each_epoch
)))
+
1
)
/
2
fluid
.
layers
.
tensor
.
assign
(
input
=
decayed_lr
,
output
=
lr
)
epoch
=
ops
.
floor
(
global_step
/
step_each_epoch
)
with
fluid
.
layers
.
control_flow
.
Switch
()
as
switch
:
with
switch
.
case
(
epoch
<
warmup_epoch
):
decayed_lr
=
learning_rate
*
(
global_step
/
(
step_each_epoch
*
warmup_epoch
))
fluid
.
layers
.
tensor
.
assign
(
input
=
decayed_lr
,
output
=
lr
)
with
switch
.
default
():
decayed_lr
=
learning_rate
*
\
(
ops
.
cos
((
global_step
-
warmup_epoch
*
step_each_epoch
)
*
(
math
.
pi
/
(
epochs
*
step_each_epoch
)))
+
1
)
/
2
fluid
.
layers
.
tensor
.
assign
(
input
=
decayed_lr
,
output
=
lr
)
return
lr
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录