Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8e55736a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
8e55736a
编写于
10月 19, 2017
作者:
Z
zchen0211
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deconv2d
上级
7eeaae16
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
11 deletion
+13
-11
paddle/operators/deconv2d_op.cc
paddle/operators/deconv2d_op.cc
+9
-7
paddle/operators/deconv2d_op.h
paddle/operators/deconv2d_op.h
+4
-4
未找到文件。
paddle/operators/deconv2d_op.cc
浏览文件 @
8e55736a
...
...
@@ -31,12 +31,14 @@ void Deconv2DOp::InferShape(framework::InferShapeContext* ctx) const {
std
::
vector
<
int
>
strides
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
for
(
in
t
i
=
0
;
i
<
paddings
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
paddings
.
size
();
++
i
)
{
PADDLE_ENFORCE_EQ
(
paddings
[
i
],
0
,
"No Padding allowed in deconv op."
);
}
PADDLE_ENFORCE_EQ
(
in_dims
.
size
(),
4
,
"Deconv2DOp input should be 4-D."
);
PADDLE_ENFORCE_EQ
(
filter_dims
.
size
(),
4
,
"Deconv2DOp filter should be 4-D."
);
PADDLE_ENFORCE_EQ
(
in_dims
.
size
(),
4
,
"Deconv2DOp input should be 4-D tensor."
);
PADDLE_ENFORCE_EQ
(
filter_dims
.
size
(),
4
,
"Deconv2DOp filter should be 4-D tensor."
);
PADDLE_ENFORCE_EQ
(
in_dims
[
1
],
filter_dims
[
0
],
"input and kernel input dimension should be equal."
);
...
...
@@ -52,14 +54,14 @@ Deconv2DOpMaker::Deconv2DOpMaker(framework::OpProto* proto,
AddInput
(
"Input"
,
"The input tensor of deconvolution operator. "
"The format of input tensor is N
MHW. Where N is batch size, M
is the "
"The format of input tensor is N
CHW. Where N is batch size, C
is the "
"number of input channels, H and W is the height and width of image."
);
AddInput
(
"Filter"
,
"The filter tensor of deconvolution operator."
"The format of the filter tensor is MCHW, where
M
is the number of "
"
input image channels, C is the number of out
put image channels, "
"The format of the filter tensor is MCHW, where
C
is the number of "
"
output image channels, M is the number of in
put image channels, "
"H and W is height and width of filter. "
"We enforce groups number == 1 and padding == 0 in
our
"
"We enforce groups number == 1 and padding == 0 in "
"deconvolution Scenario."
);
AddOutput
(
"Output"
,
"The output tensor of deconvolution operator."
...
...
paddle/operators/deconv2d_op.h
浏览文件 @
8e55736a
...
...
@@ -55,7 +55,7 @@ class GemmDeconv2DKernel : public framework::OpKernel<T> {
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
const
Tensor
*
input
=
context
.
Input
<
Tensor
>
(
"Input"
);
//
filter will be reshaped, so we do not use constant pointer here
//
The filter will be reshaped, so it should not be constant pointer
Tensor
filter
=
*
context
.
Input
<
Tensor
>
(
"Filter"
);
Tensor
*
output
=
context
.
Output
<
Tensor
>
(
"Output"
);
...
...
@@ -132,8 +132,8 @@ class GemmDeconvGrad2DKernel : public framework::OpKernel<T> {
const
Tensor
*
output_grad
=
context
.
Input
<
Tensor
>
(
framework
::
GradVarName
(
"Output"
));
// For filter, we do not use const pointer b/c we will do reshape
// but we should avoid modifying its value
// For filter, we do not use const pointer b/c we will do reshape
,
// but we should avoid modifying its value
.
Tensor
filter
=
*
context
.
Input
<
Tensor
>
(
"Filter"
);
Tensor
*
input_grad
=
...
...
@@ -142,7 +142,7 @@ class GemmDeconvGrad2DKernel : public framework::OpKernel<T> {
context
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"Filter"
));
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
// Actually, no paddings and groups allowed in deconv
// Actually, no paddings and groups allowed in deconv
.
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
int
N
=
input
->
dims
()[
0
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录