Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9bfa3013
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9bfa3013
编写于
12月 20, 2017
作者:
W
Wang Meng
提交者:
GitHub
12月 20, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6631 from will-am/img_separable_conv
Add separable convolution
上级
e445b3ff
7be4f2b7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
91 addition
and
12 deletion
+91
-12
python/paddle/trainer_config_helpers/networks.py
python/paddle/trainer_config_helpers/networks.py
+91
-12
未找到文件。
python/paddle/trainer_config_helpers/networks.py
浏览文件 @
9bfa3013
...
...
@@ -25,10 +25,10 @@ from paddle.trainer.config_parser import *
__all__
=
[
'sequence_conv_pool'
,
'simple_lstm'
,
"simple_img_conv_pool"
,
"img_conv_bn_pool"
,
'lstmemory_group'
,
'lstmemory_unit'
,
'small_vgg'
,
'img_conv_group'
,
'
vgg_16_network'
,
'gru_unit'
,
'gru_group'
,
'simple_gru
'
,
'
simple_attention'
,
'dot_product_attention'
,
'multi_head
_attention'
,
'
simple_gru2'
,
'bidirectional_gru'
,
'text_conv_pool'
,
'bidirectional_lstm
'
,
'inputs'
,
'outputs'
'img_conv_group'
,
'
img_separable_conv'
,
'vgg_16_network'
,
'gru_unit
'
,
'
gru_group'
,
'simple_gru'
,
'simple_attention'
,
'dot_product
_attention'
,
'
multi_head_attention'
,
'simple_gru2'
,
'bidirectional_gru
'
,
'
text_conv_pool'
,
'bidirectional_lstm'
,
'
inputs'
,
'outputs'
]
######################################################
...
...
@@ -435,6 +435,85 @@ def img_conv_group(input,
input
=
tmp
,
stride
=
pool_stride
,
pool_size
=
pool_size
,
pool_type
=
pool_type
)
@
wrap_name_default
(
"separable_conv"
)
def
img_separable_conv
(
input
,
num_channels
,
num_out_channels
,
filter_size
,
stride
=
1
,
padding
=
0
,
depth_multiplier
=
1
,
act
=
None
,
bias_attr
=
None
,
param_attr
=
None
,
shared_bias
=
True
,
layer_type
=
'exconv'
,
name
=
None
):
"""
Separable Convolution.
The separable convolution module is consisted of a depthwise convolution
that acts separately on input channels, followed by a pointwise convolution
with 1*1 kernels that mixes channels. It is used for Xception:
https://arxiv.org/pdf/1610.02357.pdf
:param input: input layer.
:type input: LayerOutput
:param num_channels: the number of input channels.
:type num_channels: int
:param num_out_channels: the number of output channels.
:type num_out_channels: int
:param filter_size: the filter size for the depthwise convolution.
:type filter_size: int|tuple
:param stride: the stride size for the depthwise convolution.
:type stride: int|tuple
:param padding: the padding size for the depthwise convolution.
:type padding: int|tuple
:param depth_multiplier: the number of filter for one channel in the
depthwize convolution.
:type depth_multiplier: int
:param act: the activation function for the output.
:type act: BaseActivation
:param bias_attr: see img_conv_layer for details.
:type bias_attr: ParameterAttribute
:param param_attr: see img_conv_layer for details.
:type param_attr: ParameterAttribute
:param shared_bias: see img_conv_layer for details.
:type shared_bias: bool
:param layer_type: see img_conv_layer for details.
:type layer_type: bool
:return: layer's output
:rtype: LayerOutput
"""
__depthwise_conv__
=
img_conv_layer
(
name
=
"%s_depthwise_conv"
%
name
,
input
=
input
,
num_channels
=
num_channels
,
num_filters
=
num_channels
*
depth_multiplier
,
groups
=
num_channels
,
filter_size
=
filter_size
,
stride
=
stride
,
padding
=
padding
,
act
=
LinearActivation
(),
bias_attr
=
bias_attr
,
param_attr
=
param_attr
,
shared_biases
=
shared_bias
,
layer_type
=
layer_type
)
__pointwise_conv__
=
img_conv_layer
(
name
=
"%s_pointwise_conv"
%
name
,
input
=
__depthwise_conv__
,
num_channels
=
num_channels
*
depth_multiplier
,
num_filters
=
num_out_channels
,
filter_size
=
1
,
stride
=
1
,
padding
=
0
,
act
=
act
,
bias_attr
=
bias_attr
,
param_attr
=
param_attr
,
shared_biases
=
shared_bias
)
return
__pointwise_conv__
def
small_vgg
(
input_image
,
num_channels
,
num_classes
):
def
__vgg__
(
ipt
,
num_filter
,
times
,
dropouts
,
num_channels_
=
None
):
return
img_conv_group
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录