Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
df7c9f2e
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看板
未验证
提交
df7c9f2e
编写于
6月 29, 2021
作者:
C
Chang Xu
提交者:
GitHub
6月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix_docs_nas (#822)
Co-authored-by:
N
ceci3
<
ceci3@users.noreply.github.com
>
上级
cdcfa69a
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
22 addition
and
22 deletion
+22
-22
docs/en/quick_start/nas_tutorial_en.md
docs/en/quick_start/nas_tutorial_en.md
+1
-1
docs/zh_cn/api_cn/dygraph/ofa/convert_supernet_api.rst
docs/zh_cn/api_cn/dygraph/ofa/convert_supernet_api.rst
+2
-2
docs/zh_cn/api_cn/static/nas/nas_api.rst
docs/zh_cn/api_cn/static/nas/nas_api.rst
+9
-9
docs/zh_cn/quick_start/static/nas_tutorial.md
docs/zh_cn/quick_start/static/nas_tutorial.md
+2
-2
docs/zh_cn/tutorials/nas/dygraph/nas_ofa.md
docs/zh_cn/tutorials/nas/dygraph/nas_ofa.md
+6
-6
docs/zh_cn/tutorials/nas/static/sanas_darts_space.md
docs/zh_cn/tutorials/nas/static/sanas_darts_space.md
+2
-2
未找到文件。
docs/en/quick_start/nas_tutorial_en.md
浏览文件 @
df7c9f2e
...
...
@@ -33,7 +33,7 @@ import numpy as np
Please set a unused port when build instance of SANAS.
```
python
sanas
=
slim
.
nas
.
SANAS
(
configs
=
[(
'MobileNetV2Space'
)],
server_addr
=
(
""
,
8
337
),
save_checkpoint
=
None
)
sanas
=
slim
.
nas
.
SANAS
(
configs
=
[(
'MobileNetV2Space'
)],
server_addr
=
(
""
,
8
911
),
save_checkpoint
=
None
)
```
## 3. define function about building program
...
...
docs/zh_cn/api_cn/dygraph/ofa/convert_supernet_api.rst
浏览文件 @
df7c9f2e
docs/zh_cn/api_cn/static/nas/nas_api.rst
浏览文件 @
df7c9f2e
...
...
@@ -88,7 +88,7 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火
from paddleslim.nas import SANAS
config = [('MobileNetV2Space')]
paddle.enable_static()
sanas = SANAS(configs=config,
,
server_addr=("",8822))
sanas = SANAS(configs=config, server_addr=("",8822))
input = paddle.static.data(name='input', shape=[None, 3, 32, 32], dtype='float32')
archs = sanas.next_archs()
for arch in archs:
...
...
@@ -115,7 +115,7 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火
from paddleslim.nas import SANAS
config = [('MobileNetV2Space')]
paddle.enable_static()
sanas = SANAS(configs=config, server_addr=
("", 888
3))
sanas = SANAS(configs=config, server_addr=
("", 882
3))
archs = sanas.next_archs()
### 假设网络计算出来的score是1,实际代码中使用时需要返回真实score。
...
...
@@ -142,7 +142,7 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火
from paddleslim.nas import SANAS
config = [('MobileNetV2Space')]
paddle.enable_static()
sanas = SANAS(configs=config, server_addr=("",
8823
))
sanas = SANAS(configs=config, server_addr=("",
8824
))
input = paddle.static.data(name='input', shape=[None, 3, 32, 32], dtype='float32')
tokens = ([0] * 25)
archs = sanas.tokens2arch(tokens)[0]
...
...
@@ -163,7 +163,7 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火
from paddleslim.nas import SANAS
config = [('MobileNetV2Space')]
paddle.enable_static()
sanas = SANAS(configs=config, server_addr=
("", 888
5))
sanas = SANAS(configs=config, server_addr=
("", 882
5))
print(sanas.current_info())
...
...
@@ -233,7 +233,7 @@ RLNAS (Reinforcement Learning Neural Architecture Search)是基于强化学习
config = [('MobileNetV2Space')]
paddle.enable_static()
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",882
4
))
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",882
6
))
.. py:method:: next_archs(obs=None)
...
...
@@ -255,7 +255,7 @@ RLNAS (Reinforcement Learning Neural Architecture Search)是基于强化学习
from paddleslim.nas import RLNAS
config = [('MobileNetV2Space')]
paddle.enable_static()
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",882
5
))
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",882
7
))
input = paddle.static.data(name='input', shape=[None, 3, 32, 32], dtype='float32')
archs = rlnas.next_archs(1)[0]
for arch in archs:
...
...
@@ -280,7 +280,7 @@ RLNAS (Reinforcement Learning Neural Architecture Search)是基于强化学习
from paddleslim.nas import RLNAS
config = [('MobileNetV2Space')]
paddle.enable_static()
rlnas = RLNAS(key='lstm', configs=config, server_addr=
("", 888
8))
rlnas = RLNAS(key='lstm', configs=config, server_addr=
("", 882
8))
rlnas.next_archs(1)
rlnas.reward(1.0)
...
...
@@ -307,7 +307,7 @@ RLNAS (Reinforcement Learning Neural Architecture Search)是基于强化学习
from paddleslim.nas import RLNAS
config = [('MobileNetV2Space')]
paddle.enable_static()
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",882
6
))
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",882
9
))
archs = rlnas.final_archs(1)
print(archs)
...
...
@@ -330,7 +330,7 @@ RLNAS (Reinforcement Learning Neural Architecture Search)是基于强化学习
from paddleslim.nas import RLNAS
config = [('MobileNetV2Space')]
paddle.enable_static()
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",88
27
))
rlnas = RLNAS(key='lstm', configs=config, server_addr=("",88
30
))
input = paddle.static.data(name='input', shape=[None, 3, 32, 32], dtype='float32')
tokens = ([0] * 25)
archs = rlnas.tokens2arch(tokens)[0]
...
...
docs/zh_cn/quick_start/static/nas_tutorial.md
浏览文件 @
df7c9f2e
...
...
@@ -160,8 +160,8 @@ sanas.reward(float(finally_reward[1]))
```
python
for
step
in
range
(
3
):
archs
=
sanas
.
next_archs
()[
0
]
exe
,
train_program
,
eval_program
,
inputs
,
avg_cost
,
acc_top1
,
acc_top5
=
build_program
(
archs
)
train_loader
,
eval_loader
=
input_data
(
i
nputs
)
exe
,
train_program
,
eval_program
,
(
images
,
label
)
,
avg_cost
,
acc_top1
,
acc_top5
=
build_program
(
archs
)
train_loader
,
eval_loader
=
input_data
(
i
mages
,
label
)
current_flops
=
slim
.
analysis
.
flops
(
train_program
)
if
current_flops
>
321208544
:
...
...
docs/zh_cn/tutorials/nas/dygraph/nas_ofa.md
浏览文件 @
df7c9f2e
...
...
@@ -16,13 +16,13 @@ OFA的基本流程分为以下步骤:
PaddleSlim提供了三种获得超网络的方式,具体可以参考
[
超网络转换
](
https://paddleslim.readthedocs.io/zh_CN/latest/api_cn/dygraph/ofa/convert_supernet_api.html
)
。
```
python
import
paddle
from
paddle.vision.models
import
mobilenet_v1
from
paddleslim.nas.ofa.convert_super
import
Convert
,
supernet
import
paddle
from
paddle.vision.models
import
mobilenet_v1
from
paddleslim.nas.ofa.convert_super
import
Convert
,
supernet
model
=
mobilenet_v1
()
sp_net_config
=
supernet
(
kernel_size
=
(
3
,
5
,
7
),
expand_ratio
=
[
1
,
2
,
4
])
sp_model
=
Convert
(
sp_net_config
).
convert
(
model
)
model
=
mobilenet_v1
()
sp_net_config
=
supernet
(
kernel_size
=
(
3
,
5
,
7
),
expand_ratio
=
[
1
,
2
,
4
])
sp_model
=
Convert
(
sp_net_config
).
convert
(
model
)
```
### 2. 训练配置
...
...
docs/zh_cn/tutorials/nas/static/sanas_darts_space.md
浏览文件 @
df7c9f2e
...
...
@@ -262,14 +262,14 @@ sa_nas.reward(float(valid_top1_list[-1] + valid_top1_list[-2]) / 2)
### 10. 利用demo下的脚本启动搜索
搜索文件位于:
[
darts_sanas_demo
](
https://github.com/PaddlePaddle/PaddleSlim/blob/develop/demo/nas/sanas_darts_space.py
)
,搜索过程中限制模型参数量为不大于3.77M。
```
python
```
shell
cd
demo/nas/
python darts_nas.py
```
### 11. 利用demo下的脚本启动最终实验
最终实验文件位于:
[
darts_sanas_demo
](
https://github.com/PaddlePaddle/PaddleSlim/blob/develop/demo/nas/sanas_darts_space.py
)
,最终实验需要训练600epoch。以下示例输入token为
`[5, 5, 0, 5, 5, 10, 7, 7, 5, 7, 7, 11, 10, 12, 10, 0, 5, 3, 10, 8]`
。
```
python
```
shell
cd
demo/nas/
python darts_nas.py
--token
5 5 0 5 5 10 7 7 5 7 7 11 10 12 10 0 5 3 10 8
--retain_epoch
600
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录