Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
5a3d1362
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5a3d1362
编写于
11月 29, 2017
作者:
C
chengduo
提交者:
GitHub
11月 29, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5951 from chengduoZH/fix_conv_doc
fix conv and conv_trans op doc
上级
1b6dcc2f
c339e1b7
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
104 addition
and
82 deletion
+104
-82
paddle/operators/conv_op.cc
paddle/operators/conv_op.cc
+36
-25
paddle/operators/conv_transpose_op.cc
paddle/operators/conv_transpose_op.cc
+47
-35
paddle/operators/conv_transpose_op.h
paddle/operators/conv_transpose_op.h
+0
-1
paddle/operators/pool_op.cc
paddle/operators/pool_op.cc
+12
-12
paddle/operators/pool_with_index_op.cc
paddle/operators/pool_with_index_op.cc
+9
-9
未找到文件。
paddle/operators/conv_op.cc
浏览文件 @
5a3d1362
...
...
@@ -97,7 +97,7 @@ Conv2DOpMaker::Conv2DOpMaker(framework::OpProto* proto,
.
SetDefault
({
0
,
0
});
AddAttr
<
int
>
(
"groups"
,
"(int default:1), the group
size of
convolution operator. "
"(int default:1), the group
s number of the
convolution operator. "
"According to grouped convolution in Alex Krizhevsky's Deep CNN paper: "
"when group=2, the first half of the filters is only connected to the "
"first half of the input channels, while the second half of the filters "
...
...
@@ -112,23 +112,29 @@ Conv2DOpMaker::Conv2DOpMaker(framework::OpProto* proto,
Convolution Operator.
The convolution operation calculates the output based on the input, filter
and strides, paddings,
groups, dilation
s parameters. The size of each dimension of the
and strides, paddings,
dilations, group
s parameters. The size of each dimension of the
parameters is checked in the infer-shape.
Input(Input
, Filter) and o
utput(Output) are in NCHW format. Where N is batch
Input(Input
) and O
utput(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(ksize, strides, paddings, dilations) are two elements.
These two elements represent height and width, respectively.
the width of the feature.
Filters(Input) is MCHW format. Where M is the number of output image channels, C is
the number of input image channels, H is the height of the filter, and W
is the width of the filter.
Parameters(strides, paddings, dilations) are two elements. These two elements represent
height and width, respectively.
The input(X) size and output(Out) size may be different.
Example:
Input:
Input shape:
(N, C_in, H_in, W_in)
Filter shape:
(C_out, C_in, H_f, W_f)
Input shape:
$(N, C_{in}, H_{in}, W_{in})$
Filter shape:
$(C_{out}, C_{in}, H_f, W_f)$
Output:
Output shape: (N, C_out, H_out, W_out)
where
H_out = (H_in + 2 * paddings[0] - (dilations[0]*(filter_size[0] - 1) + 1)) / strides[0] + 1;
W_out = (W_in + 2 * paddings[1] - (dilations[1]*(filter_size[1] - 1) + 1)) / strides[1] + 1;
Output shape: $(N, C_{out}, H_{out}, W_{out})$
Where
$$
H_{out}= \frac{(H_{in} + 2 * paddings[0] - (dilations[0] * (H_f - 1) + 1))}{strides[0]}+ 1 \\
W_{out}= \frac{(W_{in} + 2 * paddings[1] - (dilations[1] * (W_f - 1) + 1))}{strides[1]}+ 1
$$
)DOC"
);
}
...
...
@@ -165,7 +171,7 @@ Conv3DOpMaker::Conv3DOpMaker(framework::OpProto* proto,
.
SetDefault
({
0
,
0
,
0
});
AddAttr
<
int
>
(
"groups"
,
"(int default:1), the group
size of
convolution operator. "
"(int default:1), the group
s number of the
convolution operator. "
"According to grouped convolution in Alex Krizhevsky's Deep CNN paper: "
"when group=2, the first half of the filters is only connected to the "
"first half of the input channels, while the second half of the filters "
...
...
@@ -174,32 +180,37 @@ Conv3DOpMaker::Conv3DOpMaker(framework::OpProto* proto,
AddAttr
<
std
::
vector
<
int
>>
(
"dilations"
,
"(vector<int> default:{1, 1, 1}), the "
"dilations(d_dilation, h_dilation, w_dilation) of "
"convolution operator. Currently, conv3d doesn't "
"support dilation."
)
"convolution operator."
)
.
SetDefault
({
1
,
1
,
1
});
AddComment
(
R"DOC(
Convolution3D Operator.
The convolution operation calculates the output based on the input, filter
and strides, paddings, groups parameters. The size of each dimension of the
and strides, paddings,
dilations,
groups parameters. The size of each dimension of the
parameters is checked in the infer-shape.
Input(Input
, Filter) and output(Output) are in NCDHW format. W
here N is batch
Input(Input
) and output(Output) are in NCDHW format, w
here N is batch
size, C is the number of channels,D is the depth of the feature, H is the height of
the feature, and W is the width of the feature. Parameters(ksize, strides, paddings)
are three elements. These three elements represent depth, height and width, respectively.
the feature, and W is the width of the feature.
Filters(Input) is MCDHW format, where M is the number of output image channels,
C is the number of input image channels, D is the depth of the filter,
H is the height of the filter, and W is the width of the filter.
Parameters(strides, paddings, dilations) are three elements. These three elements
represent depth, height and width, respectively.
The input(X) size and output(Out) size may be different.
Example:
Input:
Input shape:
(N, C_in, D_in, H_in, W_in)
Filter shape:
(C_out, C_in, D_f, H_f, W_f)
Input shape:
$(N, C_{in}, D_{in}, H_{in}, W_{in})$
Filter shape:
$(C_{out}, C_{in}, D_f, H_f, W_f)$
Output:
Output shape: (N, C_out, D_out, H_out, W_out)
where
D_out = (D_in - filter_size[0] + 2 * paddings[0]) / strides[0] + 1;
H_out = (H_in - filter_size[1] + 2 * paddings[1]) / strides[1] + 1;
W_out = (W_in - filter_size[2] + 2 * paddings[2]) / strides[2] + 1;
Output shape: $(N, C_{out}, D_{out}, H_{out}, W_{out})$
Where
$$
D_{out}= \frac{(D_{in} + 2 * paddings[0] - (dilations[0] * (D_f - 1) + 1))}{ strides[0]}+ 1 \\
H_{out}= \frac{(H_{in} + 2 * paddings[1] - (dilations[1] * (H_f - 1) + 1))}{ strides[1]}+ 1 \\
W_{out}= \frac{(W_{in} + 2 * paddings[2] - (dilations[2] * (W_f - 1) + 1))}{ strides[2]}+ 1
$$
)DOC"
);
}
...
...
paddle/operators/conv_transpose_op.cc
浏览文件 @
5a3d1362
...
...
@@ -39,7 +39,7 @@ void ConvTransposeOp::InferShape(framework::InferShapeContext* ctx) const {
"ConvTransposeOp input dimension and strides dimension should "
"be consistent."
);
PADDLE_ENFORCE_EQ
(
paddings
.
size
(),
strides
.
size
(),
"ConvTransposeOp paddings dimension and
Conv
strides "
"ConvTransposeOp paddings dimension and strides "
"dimension should be the same."
);
PADDLE_ENFORCE_EQ
(
in_dims
[
1
],
filter_dims
[
0
],
"In ConvTransposeOp, The input channel should be the same "
...
...
@@ -62,13 +62,14 @@ Conv2DTransposeOpMaker::Conv2DTransposeOpMaker(
"The format of input tensor is NCHW. Where N is batch size, C is the "
"number of input channels, H is the height of the feature, and "
"W is the width of the feature."
);
AddInput
(
"Filter"
,
AddInput
(
"Filter"
,
"(Tensor) The filter tensor of convolution transpose operator. "
"The format of the filter tensor is CMHW, where C is the number of "
"output image channels, M is the number of input image channels, "
"The format of the filter tensor is MCHW, where M is the number of "
"input feature channels, C is the number of "
"output feature channels,"
"H is the height of the filter, and W is the width of the filter. "
"We enforce groups number == 1 and padding == 0 in "
"the convolution transpose scenario."
);
"We enforce groups number == 1 in the convolution transpose scenario."
);
AddOutput
(
"Output"
,
"(Tensor) The output tensor of convolution transpose operator. "
"The format of output tensor is also NCHW."
);
...
...
@@ -88,21 +89,26 @@ Convolution2D Transpose Operator.
The convolution transpose operation calculates the output based on the input, filter
and strides, paddings, groups parameters. The size of each dimension of the
parameters is checked in the infer-shape.
Input(Input, Filter) 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(ksize, strides, paddings) are two elements.
These two elements represent height and width, respectively.
Input(Input) and output(Output) are in NCHW format. Where N is batchsize, C is the
number of channels, H is the height of the feature, and W is the width of the feature.
Filter(Input) is in MCHW format. Where M is the number of input feature channels,
C is the number of output feature channels, H is the height of the filter,
and W is the width of the filter.
Parameters(strides, paddings) are two elements. These two elements represent height
and width, respectively.
The input(X) size and output(Out) size may be different.
Example:
Input:
Input shape:
(N, C_in, H_in, W_in)
Filter shape:
(C_in, C_out, H_f, W_f)
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
H_out = (H_in - 1) * strides[0] - 2 * paddings[0] + H_f;
W_out = (W_in - 1) * strides[1] - 2 * paddings[1] + W_f;
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
$$
)DOC"
);
}
...
...
@@ -117,8 +123,9 @@ Conv3DTransposeOpMaker::Conv3DTransposeOpMaker(
"W is the width of the feature."
);
AddInput
(
"Filter"
,
"(Tensor) The filter tensor of convolution transpose operator."
"The format of the filter tensor is CMDHW, where C is the number of "
"output image channels, M is the number of input image channels, D "
"The format of the filter tensor is MCDHW, where M is the number of "
"input feature channels, C is the number of "
"output feature channels, D "
"is the depth of the filter, H is the height of the filter, and "
"W is the width of the filter."
"We enforce groups number == 1 and padding == 0 in "
...
...
@@ -144,23 +151,28 @@ Convolution3D Transpose Operator.
The convolution transpose operation calculates the output based on the input, filter
and strides, paddings, groups parameters. The size of each dimension of the
parameters is checked in the infer-shape.
Input(Input, Filter) and output(Output) are in NCDHW format. Where N is batch
size, C is the number of channels, D is the depth of the feature,
H is the height of the feature, and W is the width of the feature.
Parameters(ksize, strides, paddings) are three elements.
These three elements represent depth, height and width, respectively.
Input(Input) and output(Output) are in NCDHW format. Where N is batch size, C is the
number of channels, D is the depth of the feature, H is the height of the feature,
and W is the width of the feature.
Filter(Input) is in MCDHW format. Where M is the number of input feature channels,
C is the number of output feature channels, D is the depth of the filter,H is the
height of the filter, and W is the width of the filter.
Parameters(strides, paddings) are three elements. These three elements represent
depth, height and width, respectively.
The input(X) size and output(Out) size may be different.
Example:
Input:
Input shape:
(N, C_in, D_in, H_in, W_in)
Filter shape:
(C_in, C_out, D_f, H_f, W_f)
Input shape:
$(N, C_{in}, D_{in}, H_{in}, W_{in})$
Filter shape:
$(C_{in}, C_{out}, D_f, H_f, W_f)$
Output:
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;
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
$$
)DOC"
);
}
...
...
paddle/operators/conv_transpose_op.h
浏览文件 @
5a3d1362
...
...
@@ -63,7 +63,6 @@ class GemmConvTransposeKernel : public framework::OpKernel<T> {
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
// TODO(Zhuoyuan): Paddings can be added in future.
// groups will alway be disabled in conv2dtranspose.
const
int
batch_size
=
static_cast
<
int
>
(
input
->
dims
()[
0
]);
...
...
paddle/operators/pool_op.cc
浏览文件 @
5a3d1362
...
...
@@ -105,7 +105,7 @@ Pool2dOpMaker::Pool2dOpMaker(framework::OpProto *proto,
// TypedAttrChecker don't support vector type.)
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"(vector<int>, defa
lu
t {0,0}), paddings(height, width) of pooling "
"(vector<int>, defa
ul
t {0,0}), paddings(height, width) of pooling "
"operator."
"If global_pooling = true, paddings and ksize will be ignored."
)
.
SetDefault
({
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
...
...
@@ -127,10 +127,10 @@ Example:
X shape: $(N, C, H_{in}, W_{in})$
Output:
Out shape: $(N, C, H_{out}, W_{out})$
where
Where
$$
H_{out} =
(H_{in} - ksize[0] + 2 * paddings[0]) / strides[0]
+ 1 \\
W_{out} =
(W_{in} - ksize[1] + 2 * paddings[1]) / strides[1]
+ 1
H_{out} =
\frac{(H_{in} - ksize[0] + 2 * paddings[0])}{strides[0]}
+ 1 \\
W_{out} =
\frac{(W_{in} - ksize[1] + 2 * paddings[1])}{strides[1]}
+ 1
$$
)DOC"
);
...
...
@@ -177,7 +177,7 @@ Pool3dOpMaker::Pool3dOpMaker(framework::OpProto *proto,
// TypedAttrChecker don't support vector type.)
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"(vector<int>, defa
lu
t {0,0,0}), paddings(depth, height, "
"(vector<int>, defa
ul
t {0,0,0}), paddings(depth, height, "
"width) of pooling operator. "
"If global_pooling = true, ksize and paddings will be ignored."
)
.
SetDefault
({
0
,
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
...
...
@@ -199,11 +199,11 @@ Example:
X shape: $(N, C, D_{in}, H_{in}, W_{in})$
Output:
Out shape: $(N, C, D_{out}, H_{out}, W_{out})$
w
here
W
here
$$
D_{out} =
(D_{in} - ksize[0] + 2 * paddings[0]) / strides[0]
+ 1 \\
H_{out} =
(H_{in} - ksize[1] + 2 * paddings[1]) / strides[1]
+ 1 \\
W_{out} =
(W_{in} - ksize[2] + 2 * paddings[2]) / strides[2]
+ 1
D_{out} =
\frac{(D_{in} - ksize[0] + 2 * paddings[0])}{strides[0]}
+ 1 \\
H_{out} =
\frac{(H_{in} - ksize[1] + 2 * paddings[1])}{strides[1]}
+ 1 \\
W_{out} =
\frac{(W_{in} - ksize[2] + 2 * paddings[2])}{strides[2]}
+ 1
$$
)DOC"
);
...
...
paddle/operators/pool_with_index_op.cc
浏览文件 @
5a3d1362
...
...
@@ -142,7 +142,7 @@ class MaxPool2dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker {
// TypedAttrChecker don't support vector type.)
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"(vector<int>, defa
lu
t:{0, 0}), paddings(height, width) of pooling "
"(vector<int>, defa
ul
t:{0, 0}), paddings(height, width) of pooling "
"operator. "
"If global_pooling = true, paddings and will be ignored."
)
.
SetDefault
({
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
...
...
@@ -166,10 +166,10 @@ Example:
Output:
Out shape: $(N, C, H_{out}, W_{out})$
Mask shape: $(N, C, H_{out}, W_{out})$
w
here
W
here
$$
H_{out} =
(H_{in} - ksize[0] + 2 * paddings[0]) / strides[0]
+ 1 \\
W_{out} =
(W_{in} - ksize[1] + 2 * paddings[1]) / strides[1]
+ 1
H_{out} =
\frac{(H_{in} - ksize[0] + 2 * paddings[0])}{strides[0]}
+ 1 \\
W_{out} =
\frac{(W_{in} - ksize[1] + 2 * paddings[1])}{strides[1]}
+ 1
$$
)DOC"
);
...
...
@@ -220,7 +220,7 @@ class MaxPool3dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker {
// TypedAttrChecker don't support vector type.)
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"(vector, defa
lu
t {0,0,0}), paddings(depth, "
"(vector, defa
ul
t {0,0,0}), paddings(depth, "
"height, width) of pooling operator. "
"If global_pooling = true, paddings and ksize will be ignored."
)
.
SetDefault
({
0
,
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
...
...
@@ -244,11 +244,11 @@ Example:
Output:
Out shape: $(N, C, D_{out}, H_{out}, W_{out})$
Mask shape: $(N, C, D_{out}, H_{out}, W_{out})$
w
here
W
here
$$
D_{out} =
(D_{in} - ksize[0] + 2 * paddings[0]) / strides[0]
+ 1 \\
H_{out} =
(H_{in} - ksize[1] + 2 * paddings[1]) / strides[1]
+ 1 \\
W_{out} =
(W_{in} - ksize[2] + 2 * paddings[2]) / strides[2]
+ 1
D_{out} =
\frac{(D_{in} - ksize[0] + 2 * paddings[0])}{strides[0]}
+ 1 \\
H_{out} =
\frac{(H_{in} - ksize[1] + 2 * paddings[1])}{strides[1]}
+ 1 \\
W_{out} =
\frac{(W_{in} - ksize[2] + 2 * paddings[2])}{strides[2]}
+ 1
$$
)DOC"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录