Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
d3a1891b
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 1 年 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d3a1891b
编写于
12月 05, 2019
作者:
C
ceci3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
77586c67
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
83 deletion
+24
-83
demo/nas/block_sa_nas_mobilenetv2.py
demo/nas/block_sa_nas_mobilenetv2.py
+1
-36
demo/nas/sa_nas_mobilenetv2.py
demo/nas/sa_nas_mobilenetv2.py
+3
-37
demo/optimizer.py
demo/optimizer.py
+20
-10
未找到文件。
demo/nas/block_sa_nas_mobilenetv2.py
浏览文件 @
d3a1891b
...
...
@@ -20,7 +20,7 @@ reduce_rate = 0.85
init_temperature
=
10.24
max_flops
=
321208544
server_address
=
""
port
=
89
0
9
port
=
89
7
9
retain_epoch
=
5
...
...
@@ -243,42 +243,7 @@ if __name__ == '__main__':
type
=
int
,
default
=
100
,
help
=
'controller server number.'
)
# optimizer args
parser
.
add_argument
(
'--lr_strategy'
,
type
=
str
,
default
=
'piecewise_decay'
,
help
=
'learning rate decay strategy.'
)
parser
.
add_argument
(
'--lr'
,
type
=
float
,
default
=
0.1
,
help
=
'learning rate.'
)
parser
.
add_argument
(
'--l2_decay'
,
type
=
float
,
default
=
1e-4
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--step_epochs'
,
nargs
=
'+'
,
type
=
int
,
default
=
[
30
,
60
,
90
],
help
=
"piecewise decay step"
)
parser
.
add_argument
(
'--momentum_rate'
,
type
=
float
,
default
=
0.9
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--warm_up_epochs'
,
type
=
float
,
default
=
5.0
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--num_epochs'
,
type
=
int
,
default
=
120
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--decay_epochs'
,
type
=
float
,
default
=
2.4
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--decay_rate'
,
type
=
float
,
default
=
0.97
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--total_images'
,
type
=
int
,
default
=
1281167
,
help
=
'learning rate decay.'
)
args
=
parser
.
parse_args
()
print
(
args
)
...
...
demo/nas/sa_nas_mobilenetv2.py
浏览文件 @
d3a1891b
...
...
@@ -22,7 +22,7 @@ reduce_rate = 0.85
init_temperature
=
10.24
max_flops
=
321208544
server_address
=
""
port
=
89
0
9
port
=
89
8
9
retain_epoch
=
5
...
...
@@ -284,6 +284,8 @@ if __name__ == '__main__':
help
=
'Whether to use GPU in train/test model.'
)
parser
.
add_argument
(
'--batch_size'
,
type
=
int
,
default
=
256
,
help
=
'batch size.'
)
parser
.
add_argument
(
'--class_dim'
,
type
=
int
,
default
=
1000
,
help
=
'classify number.'
)
parser
.
add_argument
(
'--data'
,
type
=
str
,
...
...
@@ -300,43 +302,7 @@ if __name__ == '__main__':
type
=
int
,
default
=
100
,
help
=
'controller server number.'
)
parser
.
add_argument
(
'--lr_strategy'
,
type
=
str
,
default
=
'cosine_decay'
,
help
=
'learning rate decay strategy.'
)
parser
.
add_argument
(
'--lr'
,
type
=
float
,
default
=
0.1
,
help
=
'learning rate.'
)
parser
.
add_argument
(
'--l2_decay'
,
type
=
float
,
default
=
1e-4
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--class_dim'
,
type
=
int
,
default
=
100
,
help
=
'classify number.'
)
parser
.
add_argument
(
'--step_epochs'
,
nargs
=
'+'
,
type
=
int
,
default
=
[
30
,
60
,
90
],
help
=
"piecewise decay step"
)
parser
.
add_argument
(
'--momentum_rate'
,
type
=
float
,
default
=
0.9
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--warm_up_epochs'
,
type
=
float
,
default
=
5.0
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--num_epochs'
,
type
=
int
,
default
=
120
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--decay_epochs'
,
type
=
float
,
default
=
2.4
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--decay_rate'
,
type
=
float
,
default
=
0.97
,
help
=
'learning rate decay.'
)
parser
.
add_argument
(
'--total_images'
,
type
=
int
,
default
=
1281167
,
help
=
'learning rate decay.'
)
args
=
parser
.
parse_args
()
print
(
args
)
...
...
demo/optimizer.py
浏览文件 @
d3a1891b
...
...
@@ -23,6 +23,16 @@ import paddle.fluid.layers.ops as ops
from
paddle.fluid.initializer
import
init_on_cpu
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
lr_strategy
=
'cosine_decay'
l2_decay
=
1e-4
step_epochs
=
[
30
,
60
,
90
]
momentum_rate
=
0.9
warm_up_epochs
=
5.0
num_epochs
=
120
decay_epochs
=
2.4
decay_rate
=
0.97
total_images
=
1281167
def
cosine_decay
(
learning_rate
,
step_each_epoch
,
epochs
=
120
):
"""Applies cosine decay to the learning rate.
...
...
@@ -152,15 +162,15 @@ class Optimizer(object):
def
__init__
(
self
,
args
):
self
.
batch_size
=
args
.
batch_size
self
.
lr
=
args
.
lr
self
.
lr_strategy
=
args
.
lr_strategy
self
.
l2_decay
=
args
.
l2_decay
self
.
momentum_rate
=
args
.
momentum_rate
self
.
step_epochs
=
args
.
step_epochs
self
.
num_epochs
=
args
.
num_epochs
self
.
warm_up_epochs
=
args
.
warm_up_epochs
self
.
decay_epochs
=
args
.
decay_epochs
self
.
decay_rate
=
args
.
decay_rate
self
.
total_images
=
args
.
total_images
self
.
lr_strategy
=
lr_strategy
self
.
l2_decay
=
l2_decay
self
.
momentum_rate
=
momentum_rate
self
.
step_epochs
=
step_epochs
self
.
num_epochs
=
num_epochs
self
.
warm_up_epochs
=
warm_up_epochs
self
.
decay_epochs
=
decay_epochs
self
.
decay_rate
=
decay_rate
self
.
total_images
=
total_images
self
.
step
=
int
(
math
.
ceil
(
float
(
self
.
total_images
)
/
self
.
batch_size
))
...
...
@@ -295,6 +305,6 @@ class Optimizer(object):
def
create_optimizer
(
args
):
Opt
=
Optimizer
(
args
)
optimizer
=
getattr
(
Opt
,
args
.
lr_strategy
)()
optimizer
=
getattr
(
Opt
,
lr_strategy
)()
return
optimizer
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录