Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
9b1a17a8
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9b1a17a8
编写于
1月 23, 2018
作者:
C
chengduo
提交者:
Abhinav Arora
1月 22, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine conv2d_transpose layer doc (#6920)
* refine conv2d_transpose layer doc * fix conv2d_transpose doc * fix doc
上级
cd25adbe
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
121 addition
and
73 deletion
+121
-73
paddle/operators/conv_transpose_op.cc
paddle/operators/conv_transpose_op.cc
+5
-5
paddle/operators/conv_transpose_op.h
paddle/operators/conv_transpose_op.h
+4
-5
python/paddle/v2/fluid/layers/nn.py
python/paddle/v2/fluid/layers/nn.py
+112
-63
未找到文件。
paddle/operators/conv_transpose_op.cc
浏览文件 @
9b1a17a8
...
...
@@ -160,8 +160,8 @@ Example:
Output shape: $(N, C_{out}, H_{out}, W_{out})$
Where
$$
H_{out} = (H_{in} - 1) * strides[0] - 2 * paddings[0] +
H_f
\\
W_{out} = (W_{in} - 1) * strides[1] - 2 * paddings[1] +
W_f
H_{out} = (H_{in} - 1) * strides[0] - 2 * paddings[0] +
dilations[0] * (H_f - 1) + 1
\\
W_{out} = (W_{in} - 1) * strides[1] - 2 * paddings[1] +
dilations[1] * (W_f - 1) + 1
$$
)DOC"
);
}
...
...
@@ -249,9 +249,9 @@ Example:
Output shape: $(N, C_{out}, D_{out}, H_{out}, W_{out})$
Where
$$
D_{out} = (D_{in} - 1) * strides[0] - 2 * paddings[0] +
D_f
\\
H_{out} = (H_{in} - 1) * strides[1] - 2 * paddings[1] +
H_f
\\
W_{out} = (W_{in} - 1) * strides[2] - 2 * paddings[2] +
W_f
D_{out} = (D_{in} - 1) * strides[0] - 2 * paddings[0] +
dilations[0] * (D_f - 1) + 1
\\
H_{out} = (H_{in} - 1) * strides[1] - 2 * paddings[1] +
dilations[1] * (H_f - 1) + 1
\\
W_{out} = (W_{in} - 1) * strides[2] - 2 * paddings[2] +
dilations[2] * (W_f - 1) + 1
$$
)DOC"
);
}
...
...
paddle/operators/conv_transpose_op.h
浏览文件 @
9b1a17a8
...
...
@@ -141,8 +141,8 @@ class GemmConvTransposeKernel : public framework::OpKernel<T> {
if
(
data_dim
==
2U
)
{
// col2im: col_matrix -> dy
// from (c * k_h * k_w, h * w) to (c, o_h, o_w)
col2im
(
dev_ctx
,
col
,
std
::
vector
<
int
>
{
dilations
[
0
],
dilations
[
1
]}
,
st
rides
,
st
d
::
vector
<
int
>
{
paddings
[
0
],
paddings
[
1
],
paddings
[
0
],
col2im
(
dev_ctx
,
col
,
dilations
,
strides
,
std
::
vector
<
int
>
{
paddings
[
0
],
paddings
[
1
],
paddings
[
0
],
paddings
[
1
]},
&
output_batch
);
}
else
if
(
data_dim
==
3U
)
{
...
...
@@ -247,8 +247,7 @@ class GemmConvTransposeGradKernel : public framework::OpKernel<T> {
if
(
data_dim
==
2U
)
{
// im2col: dy -> col matrix
// from (c, o_h, o_w) to (c * k_h * k_w, h * w)
im2col
(
dev_ctx
,
output_grad_batch
,
std
::
vector
<
int
>
{
dilations
[
0
],
dilations
[
1
]},
strides
,
im2col
(
dev_ctx
,
output_grad_batch
,
dilations
,
strides
,
std
::
vector
<
int
>
{
paddings
[
0
],
paddings
[
1
],
paddings
[
0
],
paddings
[
1
]},
&
col
);
...
...
python/paddle/v2/fluid/layers/nn.py
浏览文件 @
9b1a17a8
...
...
@@ -790,8 +790,8 @@ def conv2d(input,
<http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution/>`_ .
If bias attribution and activation type are provided, bias is added to the output of the convolution,
and the corresponding activation function is applied to the final result.
For each input :math:`X`, the equation is:
For each input :math:`X`, the equation is:
.. math::
...
...
@@ -808,14 +808,17 @@ def conv2d(input,
Example:
Input:
- Input:
Input shape: $(N, C_{in}, H_{in}, W_{in})$
Filter shape: $(C_{out}, C_{in}, H_f, W_f)$
Output:
-
Output:
Output shape: $(N, C_{out}, H_{out}, W_{out})$
Where
.. math::
H_{out}&=
\\
frac{(H_{in} + 2 * paddings[0] - (dilations[0] * (H_f - 1) + 1))}{strides[0]} + 1
\\\\
...
...
@@ -858,7 +861,6 @@ def conv2d(input,
data = fluid.layers.data(name='data', shape=[3, 32, 32], dtype='float32')
conv2d = fluid.layers.conv2d(input=data, num_filters=2, filter_size=3, act="relu")
"""
if
stride
is
None
:
stride
=
[
1
,
1
]
helper
=
LayerHelper
(
'conv2d'
,
**
locals
())
...
...
@@ -1212,13 +1214,51 @@ def conv2d_transpose(input,
use_cudnn
=
True
,
name
=
None
):
"""
The transpose of conv2d layer.
**Convlution2D transpose layer**
The convolution2D transpose layer calculates the output based on the input,
filter, and dilations, strides, paddings. Input(Input) and output(Output)
are in NCHW format. Where N is batch size, C is the number of channels,
H is the height of the feature, and W is the width of the feature.
Parameters(dilations, strides, paddings) are two elements. These two elements
represent height and width, respectively. The details of convolution transpose
layer, please refer to the following explanation and references `therein <http://www.matthewzeiler.com/wp-content/uploads/2017/07/cvpr2010.pdf>`_.
For each input :math:`X`, the equation is:
.. math::
Out = W
\\
ast X
In the above equation:
* :math:`X`: Input value, a tensor with NCHW format.
* :math:`W`: Filter value, a tensor with MCHW format.
* :math:`
\\
ast` : Convolution transpose operation.
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
Example:
- Input:
This layer is also known as deconvolution layer.
Input shape: $(N, C_{in}, H_{in}, W_{in})$
Filter shape: $(C_{in}, C_{out}, H_f, W_f)$
- Output:
Output shape: $(N, C_{out}, H_{out}, W_{out})$
Where
.. math::
H_{out} &= (H_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (H_f - 1) + 1
\\\\
W_{out} &= (W_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (W_f - 1) + 1
Args:
input(Variable): The input image with [N, C, H, W] format.
num_filters(int): The number of
filter. It is as same as the output
num_filters(int): The number of the
filter. It is as same as the output
image channel.
output_size(int|tuple|None): The output image size. If output size is a
tuple, it must contain two integers, (image_H, image_W). This
...
...
@@ -1226,24 +1266,33 @@ def conv2d_transpose(input,
filter_size(int|tuple|None): The filter size. If filter_size is a tuple,
it must contain two integers, (filter_size_H, filter_size_W).
Otherwise, the filter will be a square. None if use output size to
calculate filter_size
calculate filter_size.
padding(int|tuple): The padding size. If padding is a tuple, it must
contain two integers, (padding_H, padding_W). Otherwise, the
padding_H = padding_W = padding
.
padding_H = padding_W = padding. Default: padding = 0
.
stride(int|tuple): The stride size. If stride is a tuple, it must
contain two integers, (stride_H, stride_W). Otherwise, the
stride_H = stride_W = stride
.
stride_H = stride_W = stride. Default: stride = 1
.
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
.
param_attr: Parameter Attribute.
dilation_H = dilation_W = dilation. Default: dilation = 1
.
param_attr(ParamAttr): The parameters to the Conv2d_transpose Layer. Default: None
use_cudnn(bool): Use cudnn kernel or not, it is valid only when the cudnn
library is installed. Default: True
name(str|None): A name for this layer(optional). If set None, the layer
will be named automatically.
Returns:
Variable: Output image.
Variable: The tensor variable storing the convolution transpose result.
Raises:
ValueError: If the shapes of input, filter_size, stride, padding and groups mismatch.
Examples:
.. code-block:: python
data = fluid.layers.data(name='data', shape=[3, 32, 32], dtype='float32')
conv2d_transpose = fluid.layers.conv2d_transpose(input=data, num_filters=2, filter_size=3)
"""
helper
=
LayerHelper
(
"conv2d_transpose"
,
**
locals
())
if
not
isinstance
(
input
,
Variable
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录