Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
2d8a5b97
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看板
提交
2d8a5b97
编写于
9月 29, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix unit test
上级
df598899
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
25 deletion
+48
-25
paddle/operators/math/CMakeLists.txt
paddle/operators/math/CMakeLists.txt
+2
-3
python/paddle/v2/framework/tests/test_pool2d_op.py
python/paddle/v2/framework/tests/test_pool2d_op.py
+24
-12
python/paddle/v2/framework/tests/test_pool3d_op.py
python/paddle/v2/framework/tests/test_pool3d_op.py
+22
-10
未找到文件。
paddle/operators/math/CMakeLists.txt
浏览文件 @
2d8a5b97
if
(
WITH_GPU
)
if
(
WITH_GPU
)
nv_library
(
math_function SRCS math_function.cc math_function.cu im2col.cc im2col.cu pooling.cc pooling.cu DEPS cblas device_context
)
nv_library
(
math_function SRCS math_function.cc math_function.cu im2col.cc im2col.cu pooling.cc pooling.cu DEPS cblas device_context
operator
)
nv_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
nv_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
nv_library
(
softmax SRCS softmax.cc softmax.cu DEPS operator
)
nv_library
(
softmax SRCS softmax.cc softmax.cu DEPS operator
)
nv_library
(
cross_entropy SRCS cross_entropy.cc cross_entropy.cu DEPS operator
)
nv_library
(
cross_entropy SRCS cross_entropy.cc cross_entropy.cu DEPS operator
)
else
()
else
()
cc_library
(
math_function SRCS math_function.cc im2col.cc pooling.cc
cc_library
(
math_function SRCS math_function.cc im2col.cc pooling.cc DEPS cblas device_context operator
)
DEPS cblas device_context operator
)
cc_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
cc_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
cc_library
(
softmax SRCS softmax.cc DEPS operator
)
cc_library
(
softmax SRCS softmax.cc DEPS operator
)
cc_library
(
cross_entropy SRCS cross_entropy.cc DEPS operator
)
cc_library
(
cross_entropy SRCS cross_entropy.cc DEPS operator
)
...
...
python/paddle/v2/framework/tests/test_pool2d_op.py
浏览文件 @
2d8a5b97
...
@@ -47,7 +47,6 @@ def avg_pool2D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
...
@@ -47,7 +47,6 @@ def avg_pool2D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
class
TestPool2d_Op
(
OpTest
):
class
TestPool2d_Op
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
initTestCase
()
self
.
op_type
=
"pool2d"
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
.
global_pool
)
self
.
paddings
,
self
.
global_pool
)
...
@@ -71,7 +70,8 @@ class TestPool2d_Op(OpTest):
...
@@ -71,7 +70,8 @@ class TestPool2d_Op(OpTest):
self
.
check_grad
(
set
([
'X'
]),
'Out'
,
max_relative_error
=
0.07
)
self
.
check_grad
(
set
([
'X'
]),
'Out'
,
max_relative_error
=
0.07
)
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
True
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"avg"
self
.
pool_type
=
"avg"
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
]
...
@@ -82,23 +82,23 @@ class TestPool2d_Op(OpTest):
...
@@ -82,23 +82,23 @@ class TestPool2d_Op(OpTest):
class
TestCase1
(
TestPool2d_Op
):
class
TestCase1
(
TestPool2d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
False
self
.
op_type
=
"pool2d"
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"avg"
self
.
pool_type
=
"avg"
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCase2
(
TestPool2d_Op
):
class
TestCase2
(
TestPool2d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
1
self
.
global_pool
=
False
self
.
op_type
=
"pool2d"
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"avg"
self
.
pool_type
=
"avg"
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
...
@@ -106,23 +106,35 @@ class TestCase2(TestPool2d_Op):
...
@@ -106,23 +106,35 @@ class TestCase2(TestPool2d_Op):
class
TestCase3
(
TestPool2d_Op
):
class
TestCase3
(
TestPool2d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
True
self
.
op_type
=
"pool2d"
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"max"
self
.
pool_type
=
"max"
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCase
4
(
TestPool2d_Op
):
class
TestCase
3
(
TestPool2d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
1
self
.
global_pool
=
False
self
.
op_type
=
"pool2d"
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"max"
self
.
pool_type
=
"max"
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCase3
(
TestPool2d_Op
):
def
initTestCase
(
self
):
self
.
global_pool
=
False
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"max"
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
...
...
python/paddle/v2/framework/tests/test_pool3d_op.py
浏览文件 @
2d8a5b97
...
@@ -55,7 +55,6 @@ def avg_pool3D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
...
@@ -55,7 +55,6 @@ def avg_pool3D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
class
TestPool3d_Op
(
OpTest
):
class
TestPool3d_Op
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
initTestCase
()
self
.
op_type
=
"pool3d"
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
.
global_pool
)
self
.
paddings
,
self
.
global_pool
)
...
@@ -79,7 +78,8 @@ class TestPool3d_Op(OpTest):
...
@@ -79,7 +78,8 @@ class TestPool3d_Op(OpTest):
self
.
check_grad
(
set
([
'X'
]),
'Out'
,
max_relative_error
=
0.07
)
self
.
check_grad
(
set
([
'X'
]),
'Out'
,
max_relative_error
=
0.07
)
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
True
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"avg"
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
...
@@ -90,19 +90,19 @@ class TestPool3d_Op(OpTest):
...
@@ -90,19 +90,19 @@ class TestPool3d_Op(OpTest):
class
TestCase1
(
TestPool3d_Op
):
class
TestCase1
(
TestPool3d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
False
self
.
op_type
=
"pool3d"
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"avg"
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
class
TestCase2
(
TestPool3d_Op
):
class
TestCase2
(
TestPool3d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
1
self
.
global_pool
=
False
self
.
op_type
=
"pool3d"
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"avg"
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
...
@@ -114,23 +114,35 @@ class TestCase2(TestPool3d_Op):
...
@@ -114,23 +114,35 @@ class TestCase2(TestPool3d_Op):
class
TestCase3
(
TestPool3d_Op
):
class
TestCase3
(
TestPool3d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
True
self
.
op_type
=
"pool3d"
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"max"
self
.
pool_type
=
"max"
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
class
TestCase
4
(
TestPool3d_Op
):
class
TestCase
3
(
TestPool3d_Op
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
1
self
.
global_pool
=
False
self
.
op_type
=
"pool3d"
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"max"
self
.
pool_type
=
"max"
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
class
TestCase3
(
TestPool3d_Op
):
def
initTestCase
(
self
):
self
.
global_pool
=
False
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"max"
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
1
,
1
,
1
]
self
.
paddings
=
[
1
,
1
,
1
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录