Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
595ffae0
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看板
提交
595ffae0
编写于
12月 04, 2019
作者:
C
ceci3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
33653657
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
18 addition
and
20 deletion
+18
-20
paddleslim/common/sa_controller.py
paddleslim/common/sa_controller.py
+5
-9
paddleslim/nas/sa_nas.py
paddleslim/nas/sa_nas.py
+13
-11
未找到文件。
paddleslim/common/sa_controller.py
浏览文件 @
595ffae0
...
@@ -99,7 +99,6 @@ class SAController(EvolutionaryController):
...
@@ -99,7 +99,6 @@ class SAController(EvolutionaryController):
if
self
.
_checkpoints
!=
None
:
if
self
.
_checkpoints
!=
None
:
self
.
_save_checkpoint
(
self
.
_checkpoints
)
self
.
_save_checkpoint
(
self
.
_checkpoints
)
def
next_tokens
(
self
,
control_token
=
None
):
def
next_tokens
(
self
,
control_token
=
None
):
"""
"""
Get next tokens.
Get next tokens.
...
@@ -121,22 +120,19 @@ class SAController(EvolutionaryController):
...
@@ -121,22 +120,19 @@ class SAController(EvolutionaryController):
index
=
int
(
len
(
self
.
_range_table
[
0
])
*
np
.
random
.
random
())
index
=
int
(
len
(
self
.
_range_table
[
0
])
*
np
.
random
.
random
())
new_tokens
=
tokens
[:]
new_tokens
=
tokens
[:]
new_tokens
[
index
]
=
np
.
random
.
randint
(
new_tokens
[
index
]
=
np
.
random
.
randint
(
self
.
_range_table
[
0
][
index
],
self
.
_range_table
[
0
][
index
],
self
.
_range_table
[
1
][
index
])
self
.
_range_table
[
1
][
index
])
else
:
else
:
break
break
return
new_tokens
return
new_tokens
def
_save_checkpoint
(
self
,
output_
file
):
def
_save_checkpoint
(
self
,
output_
dir
):
if
not
os
.
path
.
exists
(
output_dir
):
if
not
os
.
path
.
exists
(
output_dir
):
os
.
makedirs
(
output_dir
)
os
.
makedirs
(
output_dir
)
file_path
=
os
.
path
.
join
(
output_dir
,
'sanas.checkpoints'
)
file_path
=
os
.
path
.
join
(
output_dir
,
'sanas.checkpoints'
)
scene
=
dict
()
scene
=
dict
()
for
key
in
self
.
__dict__
()
:
for
key
in
self
.
__dict__
:
if
key
in
[
'_checkpoints'
]:
if
key
in
[
'_checkpoints'
]:
continue
continue
scene
[
key
]
=
self
.
__dict__
[
key
]
scene
[
key
]
=
self
.
__dict__
[
key
]
f
=
open
(
file_path
,
'w'
)
with
open
(
file_path
,
'w'
)
as
f
:
json
.
dump
(
scene
)
json
.
dump
(
scene
,
f
)
f
.
close
()
paddleslim/nas/sa_nas.py
浏览文件 @
595ffae0
...
@@ -81,10 +81,14 @@ class SANAS(object):
...
@@ -81,10 +81,14 @@ class SANAS(object):
_logger
.
info
(
"range table: {}"
.
format
(
range_table
))
_logger
.
info
(
"range table: {}"
.
format
(
range_table
))
if
load_checkpoint
!=
None
:
if
load_checkpoint
!=
None
:
assert
os
.
path
.
exists
(
load_checkpoint
)
==
True
,
'load checkpoint file NOT EXIST!!! Please check the directory of checkpoint!!!'
assert
os
.
path
.
exists
(
checkpoint_path
=
os
.
path
.
join
(
load_checkpoint
,
'sanas.checkpoints'
)
load_checkpoint
scene
=
json
.
load
(
checkpoint_path
)
)
==
True
,
'load checkpoint file NOT EXIST!!! Please check the directory of checkpoint!!!'
preinit_tokens
=
scene
[
'_init_tokens'
]
checkpoint_path
=
os
.
path
.
join
(
load_checkpoint
,
'sanas.checkpoints'
)
with
open
(
checkpoint_path
,
'r'
)
as
f
:
scene
=
json
.
load
(
f
)
preinit_tokens
=
scene
[
'_tokens'
]
prereward
=
scene
[
'_reward'
]
prereward
=
scene
[
'_reward'
]
premax_reward
=
scene
[
'_max_reward'
]
premax_reward
=
scene
[
'_max_reward'
]
prebest_tokens
=
scene
[
'_best_tokens'
]
prebest_tokens
=
scene
[
'_best_tokens'
]
...
@@ -102,10 +106,10 @@ class SANAS(object):
...
@@ -102,10 +106,10 @@ class SANAS(object):
self
.
_init_temperature
,
self
.
_init_temperature
,
max_try_times
=
None
,
max_try_times
=
None
,
init_tokens
=
preinit_tokens
,
init_tokens
=
preinit_tokens
,
reward
=
prereward
,
reward
=
prereward
,
max_reward
=
premax_reward
,
max_reward
=
premax_reward
,
iters
=
preiter
,
iters
=
preiter
,
best_tokens
=
prebest_tokens
,
best_tokens
=
prebest_tokens
,
constrain_func
=
None
,
constrain_func
=
None
,
checkpoints
=
save_checkpoint
)
checkpoints
=
save_checkpoint
)
...
@@ -123,8 +127,6 @@ class SANAS(object):
...
@@ -123,8 +127,6 @@ class SANAS(object):
server_ip
,
server_port
,
key
=
self
.
_key
)
server_ip
,
server_port
,
key
=
self
.
_key
)
if
is_server
and
load_checkpoint
!=
None
:
if
is_server
and
load_checkpoint
!=
None
:
checkpoint_path
=
os
.
path
.
join
(
load_checkpoint
,
'sanas.checkpoints'
)
scene
=
json
.
load
(
checkpoint_path
)
self
.
_iter
=
scene
[
'_iter'
]
self
.
_iter
=
scene
[
'_iter'
]
else
:
else
:
self
.
_iter
=
0
self
.
_iter
=
0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录