Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bd561384
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
bd561384
编写于
11月 29, 2017
作者:
S
sweetsky0901
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format code
上级
d9673cad
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
133 addition
and
140 deletion
+133
-140
paddle/operators/math/unpooling.cc
paddle/operators/math/unpooling.cc
+5
-12
paddle/operators/math/unpooling.cu
paddle/operators/math/unpooling.cu
+40
-47
paddle/operators/math/unpooling.h
paddle/operators/math/unpooling.h
+4
-5
paddle/operators/unpool_op.cc
paddle/operators/unpool_op.cc
+71
-63
paddle/operators/unpool_op.h
paddle/operators/unpool_op.h
+4
-4
python/paddle/v2/fluid/tests/test_unpool_op.py
python/paddle/v2/fluid/tests/test_unpool_op.py
+9
-9
未找到文件。
paddle/operators/math/unpooling.cc
浏览文件 @
bd561384
...
@@ -17,15 +17,13 @@ limitations under the License. */
...
@@ -17,15 +17,13 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
namespace
math
{
namespace
math
{
// All tensors are in NCHW format
// All tensors are in NCHW format
template
<
typename
T
>
template
<
typename
T
>
class
Unpool2dMaxFunctor
<
platform
::
CPUPlace
,
T
>
{
class
Unpool2dMaxFunctor
<
platform
::
CPUPlace
,
T
>
{
public:
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
)
{
framework
::
Tensor
*
output
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_width
=
input
.
dims
()[
3
];
const
int
input_width
=
input
.
dims
()[
3
];
...
@@ -51,9 +49,6 @@ class Unpool2dMaxFunctor<platform::CPUPlace, T> {
...
@@ -51,9 +49,6 @@ class Unpool2dMaxFunctor<platform::CPUPlace, T> {
}
}
}
}
};
};
template
<
class
T
>
template
<
class
T
>
class
Unpool2dMaxGradFunctor
<
platform
::
CPUPlace
,
T
>
{
class
Unpool2dMaxGradFunctor
<
platform
::
CPUPlace
,
T
>
{
public:
public:
...
@@ -62,7 +57,7 @@ public:
...
@@ -62,7 +57,7 @@ public:
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
const
framework
::
Tensor
&
output_grad
,
framework
::
Tensor
*
input_grad
)
{
framework
::
Tensor
*
input_grad
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_width
=
input
.
dims
()[
3
];
const
int
input_width
=
input
.
dims
()[
3
];
...
@@ -89,12 +84,10 @@ public:
...
@@ -89,12 +84,10 @@ public:
}
}
}
}
};
};
template
class
Unpool2dMaxGradFunctor
<
platform
::
CPUPlace
,
float
>;
template
class
Unpool2dMaxGradFunctor
<
platform
::
CPUPlace
,
float
>;
template
class
Unpool2dMaxGradFunctor
<
platform
::
CPUPlace
,
double
>;
template
class
Unpool2dMaxGradFunctor
<
platform
::
CPUPlace
,
double
>;
template
class
Unpool2dMaxFunctor
<
platform
::
CPUPlace
,
float
>;
template
class
Unpool2dMaxFunctor
<
platform
::
CPUPlace
,
float
>;
template
class
Unpool2dMaxFunctor
<
platform
::
CPUPlace
,
double
>;
template
class
Unpool2dMaxFunctor
<
platform
::
CPUPlace
,
double
>;
}
// namespace math
}
// namespace math
}
// namespace operators
}
// namespace operators
}
// namespace paddle
}
// namespace paddle
paddle/operators/math/unpooling.cu
浏览文件 @
bd561384
...
@@ -18,11 +18,9 @@ limitations under the License. */
...
@@ -18,11 +18,9 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
namespace
math
{
namespace
math
{
template
<
typename
T
>
template
<
typename
T
>
__global__
void
KernelUnpool2dMax
(
const
int
nthreads
,
__global__
void
KernelUnpool2dMax
(
const
int
nthreads
,
const
T
*
input_data
,
const
T
*
input_data
,
const
int
*
indices_data
,
const
int
*
indices_data
,
const
int
input_height
,
const
int
input_height
,
const
int
input_width
,
const
int
input_width
,
const
int
channels
,
const
int
channels
,
...
@@ -46,8 +44,7 @@ __global__ void KernelUnpool2dMax(const int nthreads,
...
@@ -46,8 +44,7 @@ __global__ void KernelUnpool2dMax(const int nthreads,
}
}
}
}
template
<
typename
T
>
template
<
typename
T
>
__global__
void
KernelUnpool2dMaxGrad
(
const
int
nthreads
,
__global__
void
KernelUnpool2dMaxGrad
(
const
int
nthreads
,
const
T
*
input_data
,
const
T
*
input_data
,
const
int
*
indices_data
,
const
int
*
indices_data
,
const
int
input_height
,
const
int
input_height
,
const
int
input_width
,
const
int
input_width
,
...
@@ -78,11 +75,11 @@ __global__ void KernelUnpool2dMaxGrad(const int nthreads,
...
@@ -78,11 +75,11 @@ __global__ void KernelUnpool2dMaxGrad(const int nthreads,
*/
*/
template
<
typename
T
>
template
<
typename
T
>
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
T
>
{
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
T
>
{
public:
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
)
{
framework
::
Tensor
*
output
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_width
=
input
.
dims
()[
3
];
const
int
input_width
=
input
.
dims
()[
3
];
...
@@ -107,13 +104,13 @@ class Unpool2dMaxFunctor<platform::GPUPlace, T> {
...
@@ -107,13 +104,13 @@ class Unpool2dMaxFunctor<platform::GPUPlace, T> {
*/
*/
template
<
typename
T
>
template
<
typename
T
>
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
T
>
{
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
T
>
{
public:
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
const
framework
::
Tensor
&
output_grad
,
framework
::
Tensor
*
input_grad
)
{
framework
::
Tensor
*
input_grad
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_width
=
input
.
dims
()[
3
];
const
int
input_width
=
input
.
dims
()[
3
];
...
@@ -133,17 +130,13 @@ class Unpool2dMaxGradFunctor<platform::GPUPlace, T> {
...
@@ -133,17 +130,13 @@ class Unpool2dMaxGradFunctor<platform::GPUPlace, T> {
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
input_height
,
input_width
,
output_channels
,
input_height
,
input_width
,
output_channels
,
output_data
,
output_grad_data
,
output_data
,
output_grad_data
,
output_height
,
output_width
,
output_height
,
output_width
,
input_grad_data
);
input_grad_data
);
}
}
};
};
template
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
float
>;
template
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
float
>;
template
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
double
>;
template
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
double
>;
template
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
float
>;
template
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
float
>;
template
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
double
>;
template
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
double
>;
}
// namespace math
}
// namespace math
}
// namespace operators
}
// namespace operators
}
// namespace paddle
}
// namespace paddle
paddle/operators/math/unpooling.h
浏览文件 @
bd561384
...
@@ -22,22 +22,21 @@ namespace math {
...
@@ -22,22 +22,21 @@ namespace math {
template
<
typename
Place
,
typename
T
>
template
<
typename
Place
,
typename
T
>
class
Unpool2dMaxFunctor
{
class
Unpool2dMaxFunctor
{
public:
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
);
framework
::
Tensor
*
output
);
};
};
template
<
typename
Place
,
class
T
>
template
<
typename
Place
,
class
T
>
class
Unpool2dMaxGradFunctor
{
class
Unpool2dMaxGradFunctor
{
public:
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
const
framework
::
Tensor
&
output_grad
,
framework
::
Tensor
*
input_grad
);
framework
::
Tensor
*
input_grad
);
};
};
}
// namespace math
}
// namespace math
}
// namespace operators
}
// namespace operators
...
...
paddle/operators/unpool_op.cc
浏览文件 @
bd561384
...
@@ -21,32 +21,39 @@ class Unpool2dOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -21,32 +21,39 @@ class Unpool2dOpMaker : public framework::OpProtoAndCheckerMaker {
Unpool2dOpMaker
(
framework
::
OpProto
*
proto
,
Unpool2dOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
framework
::
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
AddInput
(
"X"
,
"(Tensor) The input tensor of unpool operator. "
"(Tensor) The input tensor of unpool operator. "
"The format of input tensor is NCHW. Where N is batch size, C is the "
"The format of input tensor is NCHW. Where N is batch size, C is the "
"number of channels, H and W is the height and width of feature."
);
"number of channels, H and W is the height and width of feature."
);
AddInput
(
"Indices"
,
AddInput
(
"Indices"
,
"(Tensor) The input tensor of the indices given out by MaxPool2d. "
"(Tensor) The input tensor of the indices given out by MaxPool2d. "
"The format of input tensor is NCHW. Where N is batch size, C is the "
"The format of input tensor is NCHW. Where N is batch size, C is the "
"number of channels, H and W is the height and width of feature."
);
"number of channels, H and W is the height and width of feature."
);
AddOutput
(
"Out"
,
AddOutput
(
"Out"
,
"(Tensor) The output tensor of unpool operator."
"(Tensor) The output tensor of unpool operator."
"The format of output tensor is also NCHW."
"The format of output tensor is also NCHW."
"Where N is batch size, C is "
"Where N is batch size, C is "
"the number of channels, H and W is the height and "
"the number of channels, H and W is the height and "
"width of feature."
);
"width of feature."
);
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"(vector), the unpooling window size(height, width) "
"(vector), the unpooling window size(height, width) "
"of unpooling operator."
);
"of unpooling operator."
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"(vector, default:{1, 1}), "
"(vector, default:{1, 1}), "
"strides (height, width) of unpooling operator."
)
"strides (height, width) of unpooling operator."
)
.
SetDefault
({
1
,
1
});
.
SetDefault
({
1
,
1
});
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"(vector defalut:{0,0}), "
"(vector defalut:{0,0}), "
"paddings (height, width) of unpooling operator."
)
"paddings (height, width) of unpooling operator."
)
.
SetDefault
({
0
,
0
});
.
SetDefault
({
0
,
0
});
AddAttr
<
std
::
string
>
(
"unpooling_type"
,
AddAttr
<
std
::
string
>
(
"unpooling_type"
,
"(string), unpooling type, can be
\"
max
\"
for max-unpooling "
)
"(string), unpooling type, can be
\"
max
\"
for max-unpooling "
)
.
InEnum
({
"max"
});
.
InEnum
({
"max"
});
AddComment
(
R"DOC(
AddComment
(
R"DOC(
...
@@ -64,12 +71,12 @@ class Unpool2dOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -64,12 +71,12 @@ class Unpool2dOpMaker : public framework::OpProtoAndCheckerMaker {
};
};
int
OutputSize
(
int
input_size
,
int
ksize
,
int
padding
,
int
stride
)
{
int
OutputSize
(
int
input_size
,
int
ksize
,
int
padding
,
int
stride
)
{
int
output_size
=
(
input_size
-
1
)
*
stride
-
2
*
padding
+
ksize
;
int
output_size
=
(
input_size
-
1
)
*
stride
-
2
*
padding
+
ksize
;
return
output_size
;
return
output_size
;
}
}
class
UnpoolOp
:
public
framework
::
OperatorWithKernel
{
class
UnpoolOp
:
public
framework
::
OperatorWithKernel
{
protected:
protected:
framework
::
OpKernelType
GetKernelType
(
framework
::
OpKernelType
GetKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
OpKernelType
(
return
framework
::
OpKernelType
(
...
@@ -77,7 +84,7 @@ protected:
...
@@ -77,7 +84,7 @@ protected:
ctx
.
device_context
());
ctx
.
device_context
());
}
}
public:
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"Input(X) of UnpoolOp"
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"Input(X) of UnpoolOp"
...
@@ -92,7 +99,8 @@ public:
...
@@ -92,7 +99,8 @@ public:
ctx
->
Attrs
().
Get
<
std
::
string
>
(
"unpooling_type"
);
ctx
->
Attrs
().
Get
<
std
::
string
>
(
"unpooling_type"
);
std
::
vector
<
int
>
ksize
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
ksize
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
strides
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
std
::
vector
<
int
>
paddings
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
PADDLE_ENFORCE
(
in_x_dims
.
size
()
==
4
,
PADDLE_ENFORCE
(
in_x_dims
.
size
()
==
4
,
"Unpooling intput must be of 4-dimensional."
);
"Unpooling intput must be of 4-dimensional."
);
PADDLE_ENFORCE_EQ
(
in_x_dims
,
in_y_dims
);
PADDLE_ENFORCE_EQ
(
in_x_dims
,
in_y_dims
);
...
@@ -129,10 +137,10 @@ class UnpoolOpGrad : public framework::OperatorWithKernel {
...
@@ -129,10 +137,10 @@ class UnpoolOpGrad : public framework::OperatorWithKernel {
namespace
ops
=
paddle
::
operators
;
namespace
ops
=
paddle
::
operators
;
REGISTER_OP
(
unpool
,
ops
::
UnpoolOp
,
ops
::
Unpool2dOpMaker
,
unpool_grad
,
REGISTER_OP
(
unpool
,
ops
::
UnpoolOp
,
ops
::
Unpool2dOpMaker
,
unpool_grad
,
ops
::
UnpoolOpGrad
);
ops
::
UnpoolOpGrad
);
REGISTER_OP_CPU_KERNEL
(
unpool
,
REGISTER_OP_CPU_KERNEL
(
ops
::
UnpoolKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
unpool
,
ops
::
UnpoolKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
ops
::
UnpoolKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
ops
::
UnpoolKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
REGISTER_OP_CPU_KERNEL
(
unpool_grad
,
REGISTER_OP_CPU_KERNEL
(
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
unpool_grad
,
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
paddle/operators/unpool_op.h
浏览文件 @
bd561384
...
@@ -27,7 +27,7 @@ class UnpoolKernel : public framework::OpKernel<T> {
...
@@ -27,7 +27,7 @@ class UnpoolKernel : public framework::OpKernel<T> {
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
const
framework
::
Tensor
*
in_x
=
context
.
Input
<
framework
::
Tensor
>
(
"X"
);
const
framework
::
Tensor
*
in_x
=
context
.
Input
<
framework
::
Tensor
>
(
"X"
);
const
framework
::
Tensor
*
in_y
=
context
.
Input
<
framework
::
Tensor
>
(
"Indices"
);
const
framework
::
Tensor
*
in_y
=
context
.
Input
<
framework
::
Tensor
>
(
"Indices"
);
auto
*
out
=
context
.
Output
<
framework
::
Tensor
>
(
"Out"
);
auto
*
out
=
context
.
Output
<
framework
::
Tensor
>
(
"Out"
);
std
::
string
unpooling_type
=
context
.
Attr
<
std
::
string
>
(
"unpooling_type"
);
std
::
string
unpooling_type
=
context
.
Attr
<
std
::
string
>
(
"unpooling_type"
);
std
::
vector
<
int
>
ksize
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
ksize
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
...
@@ -65,8 +65,8 @@ class UnpoolGradKernel : public framework::OpKernel<T> {
...
@@ -65,8 +65,8 @@ class UnpoolGradKernel : public framework::OpKernel<T> {
zero
(
device_ctx
,
in_x_grad
,
static_cast
<
T
>
(
0
));
zero
(
device_ctx
,
in_x_grad
,
static_cast
<
T
>
(
0
));
}
}
math
::
Unpool2dMaxGradFunctor
<
Place
,
T
>
unpool2d_max_backward
;
math
::
Unpool2dMaxGradFunctor
<
Place
,
T
>
unpool2d_max_backward
;
unpool2d_max_backward
(
context
.
device_context
(),
*
in_x
,
*
in_y
,
unpool2d_max_backward
(
context
.
device_context
(),
*
in_x
,
*
in_y
,
*
out
,
*
out
,
*
out
_grad
,
in_x_grad
);
*
out_grad
,
in_x_grad
);
}
}
};
};
...
...
python/paddle/v2/fluid/tests/test_unpool_op.py
浏览文件 @
bd561384
...
@@ -52,8 +52,10 @@ class TestUnpoolOp(OpTest):
...
@@ -52,8 +52,10 @@ class TestUnpoolOp(OpTest):
c_start
+
arg
%
self
.
ksize
[
1
]
c_start
+
arg
%
self
.
ksize
[
1
]
output
=
self
.
unpool2d_forward_naive
(
input
,
indices
,
self
.
ksize
,
\
output
=
self
.
unpool2d_forward_naive
(
input
,
indices
,
self
.
ksize
,
\
self
.
strides
,
self
.
paddings
).
astype
(
"float32"
)
self
.
strides
,
self
.
paddings
).
astype
(
"float32"
)
self
.
inputs
=
{
'X'
:
input
.
astype
(
'float32'
),
self
.
inputs
=
{
'Indices'
:
indices
.
astype
(
'int32'
)}
'X'
:
input
.
astype
(
'float32'
),
'Indices'
:
indices
.
astype
(
'int32'
)
}
self
.
attrs
=
{
self
.
attrs
=
{
'strides'
:
self
.
strides
,
'strides'
:
self
.
strides
,
'paddings'
:
self
.
paddings
,
'paddings'
:
self
.
paddings
,
...
@@ -76,7 +78,5 @@ class TestUnpoolOp(OpTest):
...
@@ -76,7 +78,5 @@ class TestUnpoolOp(OpTest):
self
.
strides
=
[
2
,
2
]
self
.
strides
=
[
2
,
2
]
self
.
paddings
=
[
0
,
0
]
self
.
paddings
=
[
0
,
0
]
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录