Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
68e50dc3
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看板
提交
68e50dc3
编写于
12月 02, 2019
作者:
C
ceci3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update mobilenet_block
上级
0cd9aa5e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
32 addition
and
10 deletion
+32
-10
paddleslim/nas/search_space/mobilenet_block.py
paddleslim/nas/search_space/mobilenet_block.py
+30
-8
paddleslim/nas/search_space/search_space_base.py
paddleslim/nas/search_space/search_space_base.py
+2
-2
未找到文件。
paddleslim/nas/search_space/mobilenet_block.py
浏览文件 @
68e50dc3
...
...
@@ -38,6 +38,7 @@ class MobileNetV2BlockSpace(SearchSpaceBase):
super
(
MobileNetV2BlockSpace
,
self
).
__init__
(
input_size
,
output_size
,
block_num
,
block_mask
)
if
self
.
block_mask
==
None
:
# use input_size and output_size to compute self.downsample_num
self
.
downsample_num
=
compute_downsample_num
(
self
.
input_size
,
self
.
output_size
)
if
self
.
block_num
!=
None
:
...
...
@@ -111,12 +112,23 @@ class MobileNetV2BlockSpace(SearchSpaceBase):
self
.
bottleneck_params_list
.
append
(
self
.
mutiply
[
tokens
[
j
*
4
],
self
.
filter_num
[
tokens
[
j
*
4
+
1
]],
self
.
repeat
[
tokens
[
j
*
4
+
2
]],
1
,
self
.
k_size
[
tokens
[
j
*
4
+
3
]])
def
net_arch
(
input
,
return_mid_layer
=
False
):
def
net_arch
(
input
,
return_mid_layer
=
False
,
return_block
=
[]):
assert
isinstance
(
return_block
,
list
),
'return_block must be a list.'
# all padding is 'SAME' in the conv2d, can compute the actual padding automatic.
# bottleneck sequences
in_c
=
int
(
32
*
self
.
scale
)
mid_layer
=
dict
()
layer_count
=
0
depthwise_conv
=
None
for
i
,
layer_setting
in
enumerate
(
self
.
bottleneck_params_list
):
t
,
c
,
n
,
s
,
k
=
layer_setting
if
s
==
2
:
layer_count
+=
1
if
(
layer_count
-
1
)
in
return_block
:
mid_layer
[
layer_count
]
=
depthwise_conv
input
,
depthwise_conv
=
self
.
_invresi_blocks
(
input
=
input
,
in_c
=
in_c
,
...
...
@@ -129,7 +141,7 @@ class MobileNetV2BlockSpace(SearchSpaceBase):
in_c
=
int
(
c
*
self
.
scale
)
if
return_mid_layer
:
return
input
,
depthwise_conv
return
input
,
mid_layer
else
:
return
input
,
...
...
@@ -309,12 +321,19 @@ class MobileNetV1BlockSpace(SearchSpaceBase):
self
.
bottleneck_params_list
.
append
(
self
.
filter_num
[
tokens
[
j
*
3
],
self
.
filter_num
[
tokens
[
j
*
3
+
1
]],
1
,
self
.
k_size
[
tokens
[
j
*
3
+
2
]])
def
net_arch
(
input
,
return_mid_layer
=
False
):
def
net_arch
(
input
,
return_mid_layer
=
False
,
return_block
=
[]):
assert
isinstance
(
return_block
,
list
),
'return_block must be a list.'
mid_layer
=
dict
()
layer_count
=
0
def
net_arch
(
input
):
for
i
,
layer_setting
in
enumerate
(
self
.
bottleneck_params_list
):
filter_num1
,
filter_num2
,
stride
,
kernel_size
=
layer_setting
if
stride
==
2
:
layer_count
+=
1
if
(
layer_count
-
1
)
in
return_block
:
mid_layer
[
layer_count
]
=
input
input
=
self
.
_depthwise_separable
(
input
=
input
,
num_filters1
=
filter_num1
,
...
...
@@ -324,6 +343,9 @@ class MobileNetV1BlockSpace(SearchSpaceBase):
scale
=
self
.
scale
,
kernel_size
=
kernel_size
,
name
=
'mobilenetv1_{}'
.
format
(
str
(
i
+
1
)))
if
return_mid_layer
:
return
input
,
mid_layer
else
:
return
input
return
net_arch
...
...
paddleslim/nas/search_space/search_space_base.py
浏览文件 @
68e50dc3
...
...
@@ -31,8 +31,8 @@ class SearchSpaceBase(object):
"If block_mask is NOT None, we will use block_mask as major configs!"
)
self
.
block_num
=
None
if
self
.
block_mask
==
None
and
self
.
block_num
==
None
:
print
(
"block_mask and
block num
can NOT be None at the same time!"
)
if
self
.
block_mask
==
None
and
(
self
.
block_num
==
None
or
self
.
input_size
==
None
or
self
.
output_size
==
None
)
:
print
(
"block_mask and
(block num or input_size or output_size)
can NOT be None at the same time!"
)
def
init_tokens
(
self
):
"""Get init tokens in search space.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录