Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
84a2512b
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
提交
84a2512b
编写于
9月 22, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix parameter name and function define
上级
50b8ec05
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
129 addition
and
118 deletion
+129
-118
paddle/operators/math/pooling.cc
paddle/operators/math/pooling.cc
+12
-12
paddle/operators/math/pooling.cu
paddle/operators/math/pooling.cu
+12
-12
paddle/operators/math/pooling.h
paddle/operators/math/pooling.h
+12
-12
paddle/operators/pool_op.cc
paddle/operators/pool_op.cc
+51
-36
paddle/operators/pool_op.h
paddle/operators/pool_op.h
+34
-38
python/paddle/v2/framework/tests/test_pool2d_op.py
python/paddle/v2/framework/tests/test_pool2d_op.py
+4
-4
python/paddle/v2/framework/tests/test_pool3d_op.py
python/paddle/v2/framework/tests/test_pool3d_op.py
+4
-4
未找到文件。
paddle/operators/math/pooling.cc
浏览文件 @
84a2512b
...
@@ -21,10 +21,10 @@ namespace math {
...
@@ -21,10 +21,10 @@ namespace math {
template
<
typename
PoolProcess
,
typename
T
>
template
<
typename
PoolProcess
,
typename
T
>
class
Pool2dForwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
class
Pool2dForwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
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
];
...
@@ -75,12 +75,12 @@ class Pool2dForwardFunctor<platform::CPUPlace, PoolProcess, T> {
...
@@ -75,12 +75,12 @@ class Pool2dForwardFunctor<platform::CPUPlace, PoolProcess, T> {
template
<
typename
PoolProcess
,
class
T
>
template
<
typename
PoolProcess
,
class
T
>
class
Pool2dBackwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
class
Pool2dBackwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
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
];
...
@@ -154,10 +154,10 @@ template class Pool2dBackwardFunctor<
...
@@ -154,10 +154,10 @@ template class Pool2dBackwardFunctor<
template
<
typename
PoolProcess
,
class
T
>
template
<
typename
PoolProcess
,
class
T
>
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_depth
=
input
.
dims
()[
2
];
const
int
input_depth
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
3
];
const
int
input_height
=
input
.
dims
()[
3
];
...
@@ -224,12 +224,12 @@ class Pool3dForwardFunctor<platform::CPUPlace, PoolProcess, T> {
...
@@ -224,12 +224,12 @@ class Pool3dForwardFunctor<platform::CPUPlace, PoolProcess, T> {
template
<
typename
PoolProcess
,
class
T
>
template
<
typename
PoolProcess
,
class
T
>
class
Pool3dBackwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
class
Pool3dBackwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_depth
=
input
.
dims
()[
2
];
const
int
input_depth
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
3
];
const
int
input_height
=
input
.
dims
()[
3
];
...
...
paddle/operators/math/pooling.cu
浏览文件 @
84a2512b
...
@@ -105,10 +105,10 @@ __global__ void KernelPool2dBackward(
...
@@ -105,10 +105,10 @@ __global__ void KernelPool2dBackward(
template
<
typename
PoolProcess
,
typename
T
>
template
<
typename
PoolProcess
,
typename
T
>
class
Pool2dForwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
class
Pool2dForwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
2
];
...
@@ -148,12 +148,12 @@ class Pool2dForwardFunctor<platform::GPUPlace, PoolProcess, T> {
...
@@ -148,12 +148,12 @@ class Pool2dForwardFunctor<platform::GPUPlace, PoolProcess, T> {
template
<
typename
PoolProcess
,
typename
T
>
template
<
typename
PoolProcess
,
typename
T
>
class
Pool2dBackwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
class
Pool2dBackwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
2
];
...
@@ -319,10 +319,10 @@ __global__ void KernelPool3DBackward(
...
@@ -319,10 +319,10 @@ __global__ void KernelPool3DBackward(
template
<
typename
PoolProcess
,
class
T
>
template
<
typename
PoolProcess
,
class
T
>
class
Pool3dForwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
class
Pool3dForwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_depth
=
input
.
dims
()[
2
];
const
int
input_depth
=
input
.
dims
()[
2
];
...
@@ -369,12 +369,12 @@ class Pool3dForwardFunctor<platform::GPUPlace, PoolProcess, T> {
...
@@ -369,12 +369,12 @@ class Pool3dForwardFunctor<platform::GPUPlace, PoolProcess, T> {
template
<
typename
PoolProcess
,
class
T
>
template
<
typename
PoolProcess
,
class
T
>
class
Pool3dBackwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
class
Pool3dBackwardFunctor
<
platform
::
GPUPlace
,
PoolProcess
,
T
>
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
PoolProcess
pool_process
)
{
const
platform
::
DeviceContext
&
context
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_channels
=
input
.
dims
()[
1
];
const
int
input_depth
=
input
.
dims
()[
2
];
const
int
input_depth
=
input
.
dims
()[
2
];
...
...
paddle/operators/math/pooling.h
浏览文件 @
84a2512b
...
@@ -59,41 +59,41 @@ class avePool {
...
@@ -59,41 +59,41 @@ class avePool {
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
class
Pool2dForwardFunctor
{
class
Pool2dForwardFunctor
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
);
const
platform
::
DeviceContext
&
context
);
};
};
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
class
Pool2dBackwardFunctor
{
class
Pool2dBackwardFunctor
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
PoolProcess
pool_process
);
const
platform
::
DeviceContext
&
context
);
};
};
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
class
Pool3dForwardFunctor
{
class
Pool3dForwardFunctor
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
output
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
);
const
platform
::
DeviceContext
&
context
);
};
};
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
template
<
typename
Place
,
typename
PoolProcess
,
typename
T
>
class
Pool3dBackwardFunctor
{
class
Pool3dBackwardFunctor
{
public:
public:
void
operator
()(
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
framework
::
Tensor
&
input_grad
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
const
framework
::
Tensor
&
output_grad
,
std
::
vector
<
int
>&
ksize
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
PoolProcess
pool_process
,
PoolProcess
pool_process
);
const
platform
::
DeviceContext
&
context
);
};
};
}
// namespace math
}
// namespace math
...
...
paddle/operators/pool_op.cc
浏览文件 @
84a2512b
...
@@ -28,18 +28,18 @@ class PoolOp : public framework::OperatorWithKernel {
...
@@ -28,18 +28,18 @@ class PoolOp : public framework::OperatorWithKernel {
protected:
protected:
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
PADDLE_ENFORCE_NOT_NULL
(
ctx
.
InputVar
(
"
Input
"
),
PADDLE_ENFORCE_NOT_NULL
(
ctx
.
InputVar
(
"
X
"
),
"
Input
(Input) of Pooling should not be null."
);
"
X
(Input) of Pooling should not be null."
);
PADDLE_ENFORCE_NOT_NULL
(
ctx
.
OutputVar
(
"Out
put
"
),
PADDLE_ENFORCE_NOT_NULL
(
ctx
.
OutputVar
(
"Out"
),
"Out
put
(Output) of Pooling should not be null."
);
"Out(Output) of Pooling should not be null."
);
// PADDLE_ENFORCE_NOT_NULL(Attr<std::string>("pooling
_t
ype"),
// PADDLE_ENFORCE_NOT_NULL(Attr<std::string>("pooling
T
ype"),
// "pooling_type should not be null.");
// "pooling_type should not be null.");
// PADDLE_ENFORCE_NOT_NULL(Attr<std::vector<int>>("ksize"), "ksize should
// PADDLE_ENFORCE_NOT_NULL(Attr<std::vector<int>>("ksize"), "ksize should
// not be null.");
// not be null.");
auto
in
put
=
ctx
.
Input
<
Tensor
>
(
"Input
"
);
auto
in
_X
=
ctx
.
Input
<
Tensor
>
(
"X
"
);
auto
out
put
=
ctx
.
Output
<
framework
::
LoDTensor
>
(
"Outp
ut"
);
auto
out
=
ctx
.
Output
<
framework
::
LoDTensor
>
(
"O
ut"
);
int
global_pooling
=
Attr
<
int
>
(
"global
_p
ooling"
);
int
global_pooling
=
Attr
<
int
>
(
"global
P
ooling"
);
std
::
string
pooling_type
=
Attr
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
string
pooling_type
=
Attr
<
std
::
string
>
(
"pooling
T
ype"
);
std
::
vector
<
int
>
ksize
=
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
ksize
=
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
strides
=
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
std
::
vector
<
int
>
paddings
=
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
...
@@ -50,25 +50,25 @@ class PoolOp : public framework::OperatorWithKernel {
...
@@ -50,25 +50,25 @@ class PoolOp : public framework::OperatorWithKernel {
"Pooling ksize should be 2-D or 3-D"
);
"Pooling ksize should be 2-D or 3-D"
);
if
(
global_pooling
==
1
)
{
if
(
global_pooling
==
1
)
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
ksize
[
i
]
=
in
put
->
dims
()[
i
+
2
];
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
ksize
[
i
]
=
in
_X
->
dims
()[
i
+
2
];
}
}
if
(
ksize
.
size
()
==
2
)
{
if
(
ksize
.
size
()
==
2
)
{
PADDLE_ENFORCE_EQ
(
in
put
->
dims
().
size
(),
4
,
PADDLE_ENFORCE_EQ
(
in
_X
->
dims
().
size
(),
4
,
"Pool2DOp intput should be 4-D."
);
"Pool2DOp intput should be 4-D."
);
PADDLE_ENFORCE_EQ
(
strides
.
size
(),
2
,
"Pool2DOp strides should be 2-D."
);
PADDLE_ENFORCE_EQ
(
strides
.
size
(),
2
,
"Pool2DOp strides should be 2-D."
);
PADDLE_ENFORCE_EQ
(
paddings
.
size
(),
2
,
"Pool2DOp paddings should be 2-D."
);
PADDLE_ENFORCE_EQ
(
paddings
.
size
(),
2
,
"Pool2DOp paddings should be 2-D."
);
}
else
{
}
else
{
PADDLE_ENFORCE_EQ
(
in
put
->
dims
().
size
(),
5
,
PADDLE_ENFORCE_EQ
(
in
_X
->
dims
().
size
(),
5
,
"Pool3DOp intput should be 5-D."
);
"Pool3DOp intput should be 5-D."
);
PADDLE_ENFORCE_EQ
(
strides
.
size
(),
3
,
"Pool3DOp strides should be 3-D."
);
PADDLE_ENFORCE_EQ
(
strides
.
size
(),
3
,
"Pool3DOp strides should be 3-D."
);
PADDLE_ENFORCE_EQ
(
paddings
.
size
(),
3
,
"Pool3DOp paddings should be 3-D."
);
PADDLE_ENFORCE_EQ
(
paddings
.
size
(),
3
,
"Pool3DOp paddings should be 3-D."
);
}
}
std
::
vector
<
int64_t
>
output_shape
({
in
put
->
dims
()[
0
],
input
->
dims
()[
1
]});
std
::
vector
<
int64_t
>
output_shape
({
in
_X
->
dims
()[
0
],
in_X
->
dims
()[
1
]});
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
output_shape
.
push_back
(
outputSize_pool
(
in
put
->
dims
()[
i
+
2
],
ksize
[
i
],
output_shape
.
push_back
(
outputSize_pool
(
in
_X
->
dims
()[
i
+
2
],
ksize
[
i
],
paddings
[
i
],
strides
[
i
]));
paddings
[
i
],
strides
[
i
]));
}
}
out
put
->
Resize
(
framework
::
make_ddim
(
output_shape
));
out
->
Resize
(
framework
::
make_ddim
(
output_shape
));
}
}
};
};
...
@@ -78,9 +78,8 @@ class PoolOpGrad : public framework::OperatorWithKernel {
...
@@ -78,9 +78,8 @@ class PoolOpGrad : public framework::OperatorWithKernel {
protected:
protected:
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
auto
in
=
ctx
.
Input
<
Tensor
>
(
"Input"
);
auto
in
=
ctx
.
Input
<
Tensor
>
(
"X"
);
auto
d_in
=
auto
d_in
=
ctx
.
Output
<
framework
::
LoDTensor
>
(
framework
::
GradVarName
(
"X"
));
ctx
.
Output
<
framework
::
LoDTensor
>
(
framework
::
GradVarName
(
"Input"
));
if
(
d_in
)
d_in
->
Resize
(
in
->
dims
());
if
(
d_in
)
d_in
->
Resize
(
in
->
dims
());
}
}
};
};
...
@@ -90,27 +89,36 @@ class Pool3dOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -90,27 +89,36 @@ class Pool3dOpMaker : public framework::OpProtoAndCheckerMaker {
Pool3dOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
Pool3dOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
AddInput
(
"
Input
"
,
"
X
"
,
"The input tensor of pooling operator. "
"The input tensor of pooling operator. "
"The format of input tensor is NCDHW. Where N is batch size, C is the "
"The format of input tensor is NCDHW. Where N is batch size, C is the "
"number of channels, D, H and W is the depth, height and width of "
"number of channels, D, H and W is the depth, height and width of "
"image."
);
"image."
);
AddOutput
(
"Out
put
"
,
AddOutput
(
"Out"
,
"The output tensor of pooling operator."
"The output tensor of pooling operator."
"The format of output tensor is also NCDHW."
);
"The format of output tensor is also NCDHW."
);
AddAttr
<
std
::
string
>
(
"pooling_type"
,
AddAttr
<
std
::
string
>
(
"poolingType"
,
"pooling_type of pooling operator.['max' or 'ave']"
);
"poolingType of pooling operator.['max' or 'ave']"
);
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"strides of pooling operator."
);
AddAttr
<
std
::
vector
<
int
>>
(
AddAttr
<
int
>
(
"global_pooling"
,
"whether to use the global_pooling."
)
"ksize"
,
"pooling size(depth, height, width) of pooling operator."
);
AddAttr
<
int
>
(
"globalPooling"
,
"default 0"
"whether to use the globalPooling."
)
.
SetDefault
(
0
);
.
SetDefault
(
0
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"strides of pooling operator."
)
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"default {1,1,1}"
"strides(depth, height, width) of pooling operator."
)
.
SetDefault
({
1
,
1
,
1
});
.
SetDefault
({
1
,
1
,
1
});
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"paddings of pooling operator."
)
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"default {0,0,0}"
"paddings(depth, height, width) of pooling operator."
)
.
SetDefault
({
0
,
0
,
0
});
.
SetDefault
({
0
,
0
,
0
});
AddComment
(
R"DOC(
AddComment
(
R"DOC(
The pooling3d operation calculates the output based on
The pooling3d operation calculates the output based on
the input, pooling
_t
ype and ksize, strides, paddings parameters.
the input, pooling
T
ype and ksize, strides, paddings parameters.
)DOC"
);
)DOC"
);
}
}
};
};
...
@@ -120,26 +128,33 @@ class Pool2dOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -120,26 +128,33 @@ class Pool2dOpMaker : public framework::OpProtoAndCheckerMaker {
Pool2dOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
Pool2dOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
AddInput
(
"
Input
"
,
"
X
"
,
"The input tensor of pooling operator. "
"The input tensor of pooling 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 image."
);
"number of channels, H and W is the height and width of image."
);
AddOutput
(
"Out
put
"
,
AddOutput
(
"Out"
,
"The output tensor of pooling operator."
"The output tensor of pooling operator."
"The format of output tensor is also NCHW."
);
"The format of output tensor is also NCHW."
);
AddAttr
<
std
::
string
>
(
"pooling_type"
,
AddAttr
<
std
::
string
>
(
"poolingType"
,
"pooling_type of pooling operator.['max' or 'ave']"
);
"poolingType of pooling operator.['max' or 'ave']"
);
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"strides of pooling operator."
);
AddAttr
<
std
::
vector
<
int
>>
(
AddAttr
<
int
>
(
"global_pooling"
,
"whether to use the global_pooling."
)
"ksize"
,
"pooling size(height, width) of pooling operator."
);
AddAttr
<
int
>
(
"globalPooling"
,
"default 0"
"whether to use the globalPooling.[0 or 1]"
)
.
SetDefault
(
0
);
.
SetDefault
(
0
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"strides of pooling operator."
)
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"default {1, 1}"
"strides(height, width) of pooling operator."
)
.
SetDefault
({
1
,
1
});
.
SetDefault
({
1
,
1
});
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"paddings of pooling operator."
)
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"default {0, 0}"
"paddings(height, width) of pooling operator."
)
.
SetDefault
({
0
,
0
});
.
SetDefault
({
0
,
0
});
AddComment
(
R"DOC(
AddComment
(
R"DOC(
The pooling2d operation calculates the output based on
The pooling2d operation calculates the output based on
the input, pooling
_t
ype and ksize, strides, paddings parameters.
the input, pooling
T
ype and ksize, strides, paddings parameters.
)DOC"
);
)DOC"
);
}
}
};
};
...
...
paddle/operators/pool_op.h
浏览文件 @
84a2512b
...
@@ -28,17 +28,17 @@ template <typename Place, typename T>
...
@@ -28,17 +28,17 @@ template <typename Place, typename T>
class
PoolKernel
:
public
framework
::
OpKernel
{
class
PoolKernel
:
public
framework
::
OpKernel
{
public:
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
const
Tensor
*
in
put
=
context
.
Input
<
Tensor
>
(
"Input
"
);
const
Tensor
*
in
_X
=
context
.
Input
<
Tensor
>
(
"X
"
);
Tensor
*
out
put
=
context
.
Output
<
Tensor
>
(
"Outp
ut"
);
Tensor
*
out
=
context
.
Output
<
Tensor
>
(
"O
ut"
);
int
global_pooling
=
context
.
Attr
<
int
>
(
"global
_p
ooling"
);
int
global_pooling
=
context
.
Attr
<
int
>
(
"global
P
ooling"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
T
ype"
);
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"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
global_pooling
==
1
)
{
if
(
global_pooling
==
1
)
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
ksize
[
i
]
=
in
put
->
dims
()[
i
+
2
];
ksize
[
i
]
=
in
_X
->
dims
()[
i
+
2
];
}
}
}
}
...
@@ -49,16 +49,16 @@ class PoolKernel : public framework::OpKernel {
...
@@ -49,16 +49,16 @@ class PoolKernel : public framework::OpKernel {
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
pool2d_forward
;
pool2d_forward
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
pool2d_forward
(
*
input
,
*
output
,
ksize
,
strides
,
padding
s
,
pool2d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
stride
s
,
p
ool_process
,
context
.
device_context
()
);
p
addings
,
pool_process
);
}
else
if
(
pooling_type
==
"ave"
)
{
}
else
if
(
pooling_type
==
"ave"
)
{
paddle
::
operators
::
math
::
Pool2dForwardFunctor
<
paddle
::
operators
::
math
::
Pool2dForwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
pool2d_forward
;
pool2d_forward
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
pool2d_forward
(
*
input
,
*
output
,
ksize
,
strides
,
padding
s
,
pool2d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
stride
s
,
p
ool_process
,
(
context
.
device_context
())
);
p
addings
,
pool_process
);
}
}
}
break
;
}
break
;
case
3
:
{
case
3
:
{
...
@@ -67,15 +67,15 @@ class PoolKernel : public framework::OpKernel {
...
@@ -67,15 +67,15 @@ class PoolKernel : public framework::OpKernel {
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
pool3d_forward
;
pool3d_forward
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
pool3d_forward
(
*
input
,
*
output
,
ksize
,
strides
,
padding
s
,
pool3d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
stride
s
,
p
ool_process
,
context
.
device_context
()
);
p
addings
,
pool_process
);
}
else
if
(
pooling_type
==
"ave"
)
{
}
else
if
(
pooling_type
==
"ave"
)
{
paddle
::
operators
::
math
::
Pool3dForwardFunctor
<
paddle
::
operators
::
math
::
Pool3dForwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
pool3d_forward
;
pool3d_forward
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
pool3d_forward
(
*
input
,
*
output
,
ksize
,
strides
,
padding
s
,
pool3d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
stride
s
,
p
ool_process
,
context
.
device_context
()
);
p
addings
,
pool_process
);
}
}
}
break
;
}
break
;
}
}
...
@@ -86,26 +86,26 @@ template <typename Place, typename T>
...
@@ -86,26 +86,26 @@ template <typename Place, typename T>
class
PoolGradKernel
:
public
framework
::
OpKernel
{
class
PoolGradKernel
:
public
framework
::
OpKernel
{
public:
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
const
Tensor
*
in
put
=
context
.
Input
<
Tensor
>
(
"Input
"
);
const
Tensor
*
in
_X
=
context
.
Input
<
Tensor
>
(
"X
"
);
const
Tensor
*
out
put
=
context
.
Input
<
Tensor
>
(
"Outp
ut"
);
const
Tensor
*
out
=
context
.
Input
<
Tensor
>
(
"O
ut"
);
const
Tensor
*
out
put
_grad
=
const
Tensor
*
out_grad
=
context
.
Input
<
Tensor
>
(
framework
::
GradVarName
(
"Out
put
"
));
context
.
Input
<
Tensor
>
(
framework
::
GradVarName
(
"Out"
));
Tensor
*
in
put
_grad
=
Tensor
*
in
_X
_grad
=
context
.
Output
<
framework
::
LoDTensor
>
(
framework
::
GradVarName
(
"
Input
"
));
context
.
Output
<
framework
::
LoDTensor
>
(
framework
::
GradVarName
(
"
X
"
));
int
global_pooling
=
context
.
Attr
<
int
>
(
"global
_p
ooling"
);
int
global_pooling
=
context
.
Attr
<
int
>
(
"global
P
ooling"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
T
ype"
);
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"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
global_pooling
==
1
)
{
if
(
global_pooling
==
1
)
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
ksize
[
i
]
=
in
put
->
dims
()[
i
+
2
];
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
ksize
[
i
]
=
in
_X
->
dims
()[
i
+
2
];
}
}
if
(
in
put
_grad
)
{
if
(
in
_X
_grad
)
{
in
put
_grad
->
mutable_data
<
T
>
(
context
.
GetPlace
());
in
_X
_grad
->
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
temp
=
framework
::
EigenVector
<
T
>::
Flatten
(
*
in
put
_grad
);
auto
temp
=
framework
::
EigenVector
<
T
>::
Flatten
(
*
in
_X
_grad
);
temp
.
device
(
context
.
GetEigenDevice
<
Place
>
())
=
temp
.
device
(
context
.
GetEigenDevice
<
Place
>
())
=
temp
.
constant
(
static_cast
<
T
>
(
0
));
temp
.
constant
(
static_cast
<
T
>
(
0
));
...
@@ -116,17 +116,15 @@ class PoolGradKernel : public framework::OpKernel {
...
@@ -116,17 +116,15 @@ class PoolGradKernel : public framework::OpKernel {
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
pool2d_backward
;
pool2d_backward
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
pool2d_backward
(
*
input
,
*
input_grad
,
*
output
,
*
output_grad
,
ksize
,
pool2d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
strides
,
paddings
,
pool_process
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
context
.
device_context
());
}
else
if
(
pooling_type
==
"ave"
)
{
}
else
if
(
pooling_type
==
"ave"
)
{
paddle
::
operators
::
math
::
Pool2dBackwardFunctor
<
paddle
::
operators
::
math
::
Pool2dBackwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
pool2d_backward
;
pool2d_backward
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
pool2d_backward
(
*
input
,
*
input_grad
,
*
output
,
*
output_grad
,
ksize
,
pool2d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
strides
,
paddings
,
pool_process
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
context
.
device_context
());
}
}
}
break
;
}
break
;
case
3
:
{
case
3
:
{
...
@@ -135,17 +133,15 @@ class PoolGradKernel : public framework::OpKernel {
...
@@ -135,17 +133,15 @@ class PoolGradKernel : public framework::OpKernel {
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
pool3d_backward
;
pool3d_backward
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
pool3d_backward
(
*
input
,
*
input_grad
,
*
output
,
*
output_grad
,
ksize
,
pool3d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
strides
,
paddings
,
pool_process
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
context
.
device_context
());
}
else
if
(
pooling_type
==
"ave"
)
{
}
else
if
(
pooling_type
==
"ave"
)
{
paddle
::
operators
::
math
::
Pool3dBackwardFunctor
<
paddle
::
operators
::
math
::
Pool3dBackwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
,
T
>
pool3d_backward
;
pool3d_backward
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
avePool
<
T
>
pool_process
;
pool3d_backward
(
*
input
,
*
input_grad
,
*
output
,
*
output_grad
,
ksize
,
pool3d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
strides
,
paddings
,
pool_process
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
context
.
device_context
());
}
}
}
break
;
}
break
;
}
}
...
...
python/paddle/v2/framework/tests/test_pool2d_op.py
浏览文件 @
84a2512b
...
@@ -47,23 +47,23 @@ class TestPool2d_Op(OpTest):
...
@@ -47,23 +47,23 @@ class TestPool2d_Op(OpTest):
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float32"
)
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float32"
)
output
=
self
.
pool2D_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
output
=
self
.
pool2D_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
self
.
paddings
)
self
.
paddings
)
self
.
inputs
=
{
'
Input
'
:
input
}
self
.
inputs
=
{
'
X
'
:
input
}
self
.
attrs
=
{
self
.
attrs
=
{
'strides'
:
self
.
strides
,
'strides'
:
self
.
strides
,
'paddings'
:
self
.
paddings
,
'paddings'
:
self
.
paddings
,
'ksize'
:
self
.
ksize
,
'ksize'
:
self
.
ksize
,
'pooling
_t
ype'
:
self
.
pool_type
,
'pooling
T
ype'
:
self
.
pool_type
,
}
}
self
.
outputs
=
{
'Out
put
'
:
output
}
self
.
outputs
=
{
'Out'
:
output
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
()
self
.
check_output
()
def
test_check_grad
(
self
):
def
test_check_grad
(
self
):
if
self
.
pool_type
!=
"max"
:
if
self
.
pool_type
!=
"max"
:
self
.
check_grad
(
set
([
'
Input'
]),
'Outp
ut'
,
max_relative_error
=
0.07
)
self
.
check_grad
(
set
([
'
X'
]),
'O
ut'
,
max_relative_error
=
0.07
)
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
pool_type
=
"ave"
self
.
pool_type
=
"ave"
...
...
python/paddle/v2/framework/tests/test_pool3d_op.py
浏览文件 @
84a2512b
...
@@ -57,23 +57,23 @@ class TestPool3d_Op(OpTest):
...
@@ -57,23 +57,23 @@ class TestPool3d_Op(OpTest):
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float32"
)
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float32"
)
output
=
self
.
pool3D_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
output
=
self
.
pool3D_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
self
.
paddings
)
self
.
paddings
)
self
.
inputs
=
{
'
Input
'
:
input
}
self
.
inputs
=
{
'
X
'
:
input
}
self
.
attrs
=
{
self
.
attrs
=
{
'strides'
:
self
.
strides
,
'strides'
:
self
.
strides
,
'paddings'
:
self
.
paddings
,
'paddings'
:
self
.
paddings
,
'ksize'
:
self
.
ksize
,
'ksize'
:
self
.
ksize
,
'pooling
_t
ype'
:
self
.
pool_type
,
'pooling
T
ype'
:
self
.
pool_type
,
}
}
self
.
outputs
=
{
'Out
put
'
:
output
}
self
.
outputs
=
{
'Out'
:
output
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
()
self
.
check_output
()
def
test_check_grad
(
self
):
def
test_check_grad
(
self
):
if
self
.
pool_type
!=
"max"
:
if
self
.
pool_type
!=
"max"
:
self
.
check_grad
(
set
([
'
Input'
]),
'Outp
ut'
,
max_relative_error
=
0.07
)
self
.
check_grad
(
set
([
'
X'
]),
'O
ut'
,
max_relative_error
=
0.07
)
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
pool_type
=
"ave"
self
.
pool_type
=
"ave"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录