Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
e0bc942c
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e0bc942c
编写于
3月 20, 2018
作者:
W
wangyang59
提交者:
GitHub
3月 20, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9224 from wangyang59/dilateconv
expose dilation to conv2d and bias/act to con2d_trans
上级
c1e9b1e3
26734cfe
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
3 deletion
+18
-3
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+18
-3
未找到文件。
python/paddle/fluid/layers/nn.py
浏览文件 @
e0bc942c
...
@@ -1117,12 +1117,14 @@ def conv2d(input,
...
@@ -1117,12 +1117,14 @@ def conv2d(input,
filter_size
,
filter_size
,
stride
=
1
,
stride
=
1
,
padding
=
0
,
padding
=
0
,
dilation
=
1
,
groups
=
None
,
groups
=
None
,
param_attr
=
None
,
param_attr
=
None
,
bias_attr
=
None
,
bias_attr
=
None
,
use_cudnn
=
True
,
use_cudnn
=
True
,
use_mkldnn
=
False
,
use_mkldnn
=
False
,
act
=
None
):
act
=
None
,
name
=
None
):
"""
"""
**Convlution2D Layer**
**Convlution2D Layer**
...
@@ -1183,6 +1185,9 @@ def conv2d(input,
...
@@ -1183,6 +1185,9 @@ def conv2d(input,
padding(int|tuple): The padding size. If padding is a tuple, it must
padding(int|tuple): The padding size. If padding is a tuple, it must
contain two integers, (padding_H, padding_W). Otherwise, the
contain two integers, (padding_H, padding_W). Otherwise, the
padding_H = padding_W = padding. Default: padding = 0.
padding_H = padding_W = padding. Default: padding = 0.
dilation(int|tuple): The dilation size. If dilation is a tuple, it must
contain two integers, (dilation_H, dilation_W). Otherwise, the
dilation_H = dilation_W = dilation. Default: dilation = 1.
groups(int): The groups number of the Conv2d Layer. According to grouped
groups(int): The groups number of the Conv2d Layer. According to grouped
convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
the first half of the filters is only connected to the first half
the first half of the filters is only connected to the first half
...
@@ -1193,6 +1198,8 @@ def conv2d(input,
...
@@ -1193,6 +1198,8 @@ def conv2d(input,
use_cudnn(bool): Use cudnn kernel or not, it is valid only when the cudnn
use_cudnn(bool): Use cudnn kernel or not, it is valid only when the cudnn
library is installed. Default: True
library is installed. Default: True
act(str): Activation type. Default: None
act(str): Activation type. Default: None
name(str|None): A name for this layer(optional). If set None, the layer
will be named automatically.
Returns:
Returns:
Variable: The tensor variable storing the convolution and
\
Variable: The tensor variable storing the convolution and
\
...
@@ -1233,6 +1240,7 @@ def conv2d(input,
...
@@ -1233,6 +1240,7 @@ def conv2d(input,
filter_size
=
utils
.
convert_to_list
(
filter_size
,
2
,
'filter_size'
)
filter_size
=
utils
.
convert_to_list
(
filter_size
,
2
,
'filter_size'
)
stride
=
utils
.
convert_to_list
(
stride
,
2
,
'stride'
)
stride
=
utils
.
convert_to_list
(
stride
,
2
,
'stride'
)
padding
=
utils
.
convert_to_list
(
padding
,
2
,
'padding'
)
padding
=
utils
.
convert_to_list
(
padding
,
2
,
'padding'
)
dilation
=
utils
.
convert_to_list
(
dilation
,
2
,
'dilation'
)
if
not
isinstance
(
use_cudnn
,
bool
):
if
not
isinstance
(
use_cudnn
,
bool
):
raise
ValueError
(
"use_cudnn should be True or False"
)
raise
ValueError
(
"use_cudnn should be True or False"
)
...
@@ -1262,6 +1270,7 @@ def conv2d(input,
...
@@ -1262,6 +1270,7 @@ def conv2d(input,
attrs
=
{
attrs
=
{
'strides'
:
stride
,
'strides'
:
stride
,
'paddings'
:
padding
,
'paddings'
:
padding
,
'dilations'
:
dilation
,
'groups'
:
groups
,
'groups'
:
groups
,
'use_cudnn'
:
use_cudnn
,
'use_cudnn'
:
use_cudnn
,
'use_mkldnn'
:
use_mkldnn
'use_mkldnn'
:
use_mkldnn
...
@@ -1670,7 +1679,9 @@ def conv2d_transpose(input,
...
@@ -1670,7 +1679,9 @@ def conv2d_transpose(input,
stride
=
1
,
stride
=
1
,
dilation
=
1
,
dilation
=
1
,
param_attr
=
None
,
param_attr
=
None
,
bias_attr
=
None
,
use_cudnn
=
True
,
use_cudnn
=
True
,
act
=
None
,
name
=
None
):
name
=
None
):
"""
"""
**Convlution2D transpose layer**
**Convlution2D transpose layer**
...
@@ -1739,8 +1750,10 @@ def conv2d_transpose(input,
...
@@ -1739,8 +1750,10 @@ def conv2d_transpose(input,
dilation_H = dilation_W = dilation. Default: dilation = 1.
dilation_H = dilation_W = dilation. Default: dilation = 1.
param_attr(ParamAttr): The parameters to the Conv2d_transpose Layer.
param_attr(ParamAttr): The parameters to the Conv2d_transpose Layer.
Default: None
Default: None
bias_attr(ParamAttr): Bias parameter for the Conv2d layer. Default: None
use_cudnn(bool): Use cudnn kernel or not, it is valid only when the cudnn
use_cudnn(bool): Use cudnn kernel or not, it is valid only when the cudnn
library is installed. Default: True
library is installed. Default: True
act(str): Activation type. Default: None
name(str|None): A name for this layer(optional). If set None, the layer
name(str|None): A name for this layer(optional). If set None, the layer
will be named automatically.
will be named automatically.
...
@@ -1793,12 +1806,12 @@ def conv2d_transpose(input,
...
@@ -1793,12 +1806,12 @@ def conv2d_transpose(input,
img_filter
=
helper
.
create_parameter
(
img_filter
=
helper
.
create_parameter
(
dtype
=
input
.
dtype
,
shape
=
filter_shape
,
attr
=
helper
.
param_attr
)
dtype
=
input
.
dtype
,
shape
=
filter_shape
,
attr
=
helper
.
param_attr
)
out
=
helper
.
create_tmp_variable
(
dtype
=
input
.
dtype
)
pre_bias
=
helper
.
create_tmp_variable
(
dtype
=
input
.
dtype
)
helper
.
append_op
(
helper
.
append_op
(
type
=
'conv2d_transpose'
,
type
=
'conv2d_transpose'
,
inputs
=
{
'Input'
:
[
input
],
inputs
=
{
'Input'
:
[
input
],
'Filter'
:
[
img_filter
]},
'Filter'
:
[
img_filter
]},
outputs
=
{
'Output'
:
out
},
outputs
=
{
'Output'
:
pre_bias
},
attrs
=
{
attrs
=
{
'strides'
:
stride
,
'strides'
:
stride
,
'paddings'
:
padding
,
'paddings'
:
padding
,
...
@@ -1806,6 +1819,8 @@ def conv2d_transpose(input,
...
@@ -1806,6 +1819,8 @@ def conv2d_transpose(input,
'use_cudnn'
:
use_cudnn
'use_cudnn'
:
use_cudnn
})
})
pre_act
=
helper
.
append_bias_op
(
pre_bias
,
dim_start
=
1
,
dim_end
=
2
)
out
=
helper
.
append_activation
(
pre_act
)
return
out
return
out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录