Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
3785f08f
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3785f08f
编写于
9月 30, 2019
作者:
X
xiteng1988
提交者:
whs
9月 30, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix next_tokens of controller (#20060)
* fix next_tokens of controller
上级
5f2290ab
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
14 addition
and
3 deletion
+14
-3
python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py
python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py
+9
-1
python/paddle/fluid/contrib/slim/searcher/controller.py
python/paddle/fluid/contrib/slim/searcher/controller.py
+5
-2
未找到文件。
python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py
浏览文件 @
3785f08f
...
@@ -133,11 +133,18 @@ class LightNASStrategy(Strategy):
...
@@ -133,11 +133,18 @@ class LightNASStrategy(Strategy):
self
.
_retrain_epoch
==
0
or
self
.
_retrain_epoch
==
0
or
(
context
.
epoch_id
-
self
.
start_epoch
)
%
self
.
_retrain_epoch
==
0
):
(
context
.
epoch_id
-
self
.
start_epoch
)
%
self
.
_retrain_epoch
==
0
):
_logger
.
info
(
"light nas strategy on_epoch_begin"
)
_logger
.
info
(
"light nas strategy on_epoch_begin"
)
min_flops
=
-
1
for
_
in
range
(
self
.
_max_try_times
):
for
_
in
range
(
self
.
_max_try_times
):
startup_p
,
train_p
,
test_p
,
_
,
_
,
train_reader
,
test_reader
=
context
.
search_space
.
create_net
(
startup_p
,
train_p
,
test_p
,
_
,
_
,
train_reader
,
test_reader
=
context
.
search_space
.
create_net
(
self
.
_current_tokens
)
self
.
_current_tokens
)
context
.
eval_graph
.
program
=
test_p
context
.
eval_graph
.
program
=
test_p
flops
=
context
.
eval_graph
.
flops
()
flops
=
context
.
eval_graph
.
flops
()
if
min_flops
==
-
1
:
min_flops
=
flops
min_tokens
=
self
.
_current_tokens
[:]
else
:
if
flops
<
min_flops
:
min_tokens
=
self
.
_current_tokens
[:]
if
self
.
_max_latency
>
0
:
if
self
.
_max_latency
>
0
:
latency
=
context
.
search_space
.
get_model_latency
(
test_p
)
latency
=
context
.
search_space
.
get_model_latency
(
test_p
)
_logger
.
info
(
"try [{}] with latency {} flops {}"
.
format
(
_logger
.
info
(
"try [{}] with latency {} flops {}"
.
format
(
...
@@ -147,7 +154,8 @@ class LightNASStrategy(Strategy):
...
@@ -147,7 +154,8 @@ class LightNASStrategy(Strategy):
self
.
_current_tokens
,
flops
))
self
.
_current_tokens
,
flops
))
if
flops
>
self
.
_max_flops
or
(
self
.
_max_latency
>
0
and
if
flops
>
self
.
_max_flops
or
(
self
.
_max_latency
>
0
and
latency
>
self
.
_max_latency
):
latency
>
self
.
_max_latency
):
self
.
_current_tokens
=
self
.
_search_agent
.
next_tokens
()
self
.
_current_tokens
=
self
.
_controller
.
next_tokens
(
min_tokens
)
else
:
else
:
break
break
...
...
python/paddle/fluid/contrib/slim/searcher/controller.py
浏览文件 @
3785f08f
...
@@ -123,10 +123,13 @@ class SAController(EvolutionaryController):
...
@@ -123,10 +123,13 @@ class SAController(EvolutionaryController):
_logger
.
info
(
"current_reward: {}; current tokens: {}"
.
format
(
_logger
.
info
(
"current_reward: {}; current tokens: {}"
.
format
(
self
.
_reward
,
self
.
_tokens
))
self
.
_reward
,
self
.
_tokens
))
def
next_tokens
(
self
):
def
next_tokens
(
self
,
control_token
=
None
):
"""
"""
Get next tokens.
Get next tokens.
"""
"""
if
control_token
:
tokens
=
control_token
[:]
else
:
tokens
=
self
.
_tokens
tokens
=
self
.
_tokens
new_tokens
=
tokens
[:]
new_tokens
=
tokens
[:]
index
=
int
(
len
(
self
.
_range_table
)
*
np
.
random
.
random
())
index
=
int
(
len
(
self
.
_range_table
)
*
np
.
random
.
random
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录