Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
00ae4353
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 2 年 前同步成功
通知
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看板
提交
00ae4353
编写于
11月 25, 2019
作者:
L
lvmengsi
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix_nas' into 'develop'
update mobilenetv2 space See merge request
!50
上级
1ae6cd78
acc0726f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
10 deletion
+39
-10
paddleslim/nas/search_space/mobilenetv2.py
paddleslim/nas/search_space/mobilenetv2.py
+30
-4
paddleslim/nas/search_space/search_space_base.py
paddleslim/nas/search_space/search_space_base.py
+9
-6
未找到文件。
paddleslim/nas/search_space/mobilenetv2.py
浏览文件 @
00ae4353
...
@@ -145,7 +145,18 @@ class MobileNetV2Space(SearchSpaceBase):
...
@@ -145,7 +145,18 @@ class MobileNetV2Space(SearchSpaceBase):
(
self
.
multiply
[
tokens
[
25
]],
self
.
filter_num6
[
tokens
[
26
]],
(
self
.
multiply
[
tokens
[
25
]],
self
.
filter_num6
[
tokens
[
26
]],
self
.
repeat
[
tokens
[
27
]],
1
,
self
.
k_size
[
tokens
[
28
]]))
self
.
repeat
[
tokens
[
27
]],
1
,
self
.
k_size
[
tokens
[
28
]]))
def
net_arch
(
input
):
def
net_arch
(
input
,
end_points
=
None
,
decode_points
=
None
):
decode_ends
=
dict
()
def
check_points
(
count
,
points
):
if
points
is
None
:
return
False
else
:
if
isinstance
(
points
,
list
):
return
(
True
if
count
in
points
else
False
)
else
:
return
(
True
if
count
==
points
else
False
)
#conv1
#conv1
# all padding is 'SAME' in the conv2d, can compute the actual padding automatic.
# all padding is 'SAME' in the conv2d, can compute the actual padding automatic.
input
=
conv_bn_layer
(
input
=
conv_bn_layer
(
...
@@ -156,6 +167,12 @@ class MobileNetV2Space(SearchSpaceBase):
...
@@ -156,6 +167,12 @@ class MobileNetV2Space(SearchSpaceBase):
padding
=
'SAME'
,
padding
=
'SAME'
,
act
=
'relu6'
,
act
=
'relu6'
,
name
=
'mobilenetv2_conv1_1'
)
name
=
'mobilenetv2_conv1_1'
)
layer_count
=
1
if
check_points
(
layer_count
,
decode_points
):
decode_ends
[
layer_count
]
=
input
if
check_points
(
layer_count
,
end_points
):
return
input
,
decode_ends
# bottleneck sequences
# bottleneck sequences
i
=
1
i
=
1
...
@@ -173,6 +190,13 @@ class MobileNetV2Space(SearchSpaceBase):
...
@@ -173,6 +190,13 @@ class MobileNetV2Space(SearchSpaceBase):
k
=
k
,
k
=
k
,
name
=
'mobilenetv2_conv'
+
str
(
i
))
name
=
'mobilenetv2_conv'
+
str
(
i
))
in_c
=
int
(
c
*
self
.
scale
)
in_c
=
int
(
c
*
self
.
scale
)
layer_count
+=
n
if
check_points
(
layer_count
,
decode_points
):
decode_ends
[
layer_count
]
=
depthwise_output
if
check_points
(
layer_count
,
end_points
):
return
input
,
decode_ends
# last conv
# last conv
input
=
conv_bn_layer
(
input
=
conv_bn_layer
(
...
@@ -266,6 +290,8 @@ class MobileNetV2Space(SearchSpaceBase):
...
@@ -266,6 +290,8 @@ class MobileNetV2Space(SearchSpaceBase):
name
=
name
+
'_dwise'
,
name
=
name
+
'_dwise'
,
use_cudnn
=
False
)
use_cudnn
=
False
)
depthwise_output
=
bottleneck_conv
linear_out
=
conv_bn_layer
(
linear_out
=
conv_bn_layer
(
input
=
bottleneck_conv
,
input
=
bottleneck_conv
,
num_filters
=
num_filters
,
num_filters
=
num_filters
,
...
@@ -278,7 +304,7 @@ class MobileNetV2Space(SearchSpaceBase):
...
@@ -278,7 +304,7 @@ class MobileNetV2Space(SearchSpaceBase):
out
=
linear_out
out
=
linear_out
if
ifshortcut
:
if
ifshortcut
:
out
=
self
.
_shortcut
(
input
=
input
,
data_residual
=
out
)
out
=
self
.
_shortcut
(
input
=
input
,
data_residual
=
out
)
return
out
return
out
,
depthwise_output
def
_invresi_blocks
(
self
,
input
,
in_c
,
t
,
c
,
n
,
s
,
k
,
name
=
None
):
def
_invresi_blocks
(
self
,
input
,
in_c
,
t
,
c
,
n
,
s
,
k
,
name
=
None
):
"""Build inverted residual blocks.
"""Build inverted residual blocks.
...
@@ -308,7 +334,7 @@ class MobileNetV2Space(SearchSpaceBase):
...
@@ -308,7 +334,7 @@ class MobileNetV2Space(SearchSpaceBase):
last_c
=
c
last_c
=
c
for
i
in
range
(
1
,
n
):
for
i
in
range
(
1
,
n
):
last_residual_block
=
self
.
_inverted_residual_unit
(
last_residual_block
,
depthwise_output
=
self
.
_inverted_residual_unit
(
input
=
last_residual_block
,
input
=
last_residual_block
,
num_in_filter
=
last_c
,
num_in_filter
=
last_c
,
num_filters
=
c
,
num_filters
=
c
,
...
@@ -317,4 +343,4 @@ class MobileNetV2Space(SearchSpaceBase):
...
@@ -317,4 +343,4 @@ class MobileNetV2Space(SearchSpaceBase):
filter_size
=
k
,
filter_size
=
k
,
expansion_factor
=
t
,
expansion_factor
=
t
,
name
=
name
+
'_'
+
str
(
i
+
1
))
name
=
name
+
'_'
+
str
(
i
+
1
))
return
last_residual_block
return
last_residual_block
,
depthwise_output
paddleslim/nas/search_space/search_space_base.py
浏览文件 @
00ae4353
...
@@ -19,16 +19,19 @@ class SearchSpaceBase(object):
...
@@ -19,16 +19,19 @@ class SearchSpaceBase(object):
"""Controller for Neural Architecture Search.
"""Controller for Neural Architecture Search.
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
input_size
,
output_size
,
block_num
,
block_mask
,
*
args
):
input_size
,
"""init model config
output_size
,
"""
block_num
,
block_mask
=
None
,
*
argss
):
self
.
input_size
=
input_size
self
.
input_size
=
input_size
self
.
output_size
=
output_size
self
.
output_size
=
output_size
self
.
block_num
=
block_num
self
.
block_num
=
block_num
self
.
block_mask
=
block_mask
self
.
block_mask
=
block_mask
if
self
.
block_mask
is
not
None
:
assert
isinstance
(
self
.
block_mask
,
list
),
'Block_mask must be a list.'
print
(
"If block_mask is NOT None, we will use block_mask as major configs!"
)
def
init_tokens
(
self
):
def
init_tokens
(
self
):
"""Get init tokens in search space.
"""Get init tokens in search space.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录