Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
642b3356
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2297
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看板
体验新版 GitCode,发现更多精彩内容 >>
You need to sign in or sign up before continuing.
提交
642b3356
编写于
12月 18, 2019
作者:
J
juncaipeng
提交者:
Tao Luo
12月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update test precision from fp32 to fp64 (#21805)
上级
04909137
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
45 addition
and
45 deletion
+45
-45
python/paddle/fluid/tests/unittests/test_mean_op.py
python/paddle/fluid/tests/unittests/test_mean_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py
...addle/fluid/tests/unittests/test_mine_hard_examples_op.py
+5
-5
python/paddle/fluid/tests/unittests/test_mul_op.py
python/paddle/fluid/tests/unittests/test_mul_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_multiplex_op.py
python/paddle/fluid/tests/unittests/test_multiplex_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_nearest_interp_op.py
...on/paddle/fluid/tests/unittests/test_nearest_interp_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_pixel_shuffle.py
python/paddle/fluid/tests/unittests/test_pixel_shuffle.py
+1
-1
python/paddle/fluid/tests/unittests/test_pool2d_op.py
python/paddle/fluid/tests/unittests/test_pool2d_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_pool3d_op.py
python/paddle/fluid/tests/unittests/test_pool3d_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_pool_max_op.py
python/paddle/fluid/tests/unittests/test_pool_max_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_psroi_pool_op.py
python/paddle/fluid/tests/unittests/test_psroi_pool_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_reverse_op.py
python/paddle/fluid/tests/unittests/test_reverse_op.py
+5
-5
python/paddle/fluid/tests/unittests/test_roi_align_op.py
python/paddle/fluid/tests/unittests/test_roi_align_op.py
+5
-5
python/paddle/fluid/tests/unittests/test_roi_pool_op.py
python/paddle/fluid/tests/unittests/test_roi_pool_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_scatter_nd_op.py
python/paddle/fluid/tests/unittests/test_scatter_nd_op.py
+6
-6
python/paddle/fluid/tests/unittests/test_selu_op.py
python/paddle/fluid/tests/unittests/test_selu_op.py
+1
-1
未找到文件。
python/paddle/fluid/tests/unittests/test_mean_op.py
浏览文件 @
642b3356
...
@@ -25,7 +25,7 @@ from paddle.fluid import Program, program_guard
...
@@ -25,7 +25,7 @@ from paddle.fluid import Program, program_guard
class
TestMeanOp
(
OpTest
):
class
TestMeanOp
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"mean"
self
.
op_type
=
"mean"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_dtype_type
()
self
.
init_dtype_type
()
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
10
,
10
)).
astype
(
self
.
dtype
)}
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
10
,
10
)).
astype
(
self
.
dtype
)}
self
.
outputs
=
{
'Out'
:
np
.
mean
(
self
.
inputs
[
"X"
])}
self
.
outputs
=
{
'Out'
:
np
.
mean
(
self
.
inputs
[
"X"
])}
...
...
python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py
浏览文件 @
642b3356
...
@@ -59,13 +59,13 @@ class TestMineHardExamplesOp(OpTest):
...
@@ -59,13 +59,13 @@ class TestMineHardExamplesOp(OpTest):
self
.
sample_size
=
0
self
.
sample_size
=
0
self
.
mining_type
=
"max_negative"
self
.
mining_type
=
"max_negative"
self
.
cls_loss
=
np
.
array
([[
0.1
,
0.1
,
0.3
],
self
.
cls_loss
=
np
.
array
([[
0.1
,
0.1
,
0.3
],
[
0.3
,
0.1
,
0.1
]]).
astype
(
'float
32
'
)
[
0.3
,
0.1
,
0.1
]]).
astype
(
'float
64
'
)
self
.
loc_loss
=
np
.
array
([[
0.1
,
0.2
,
0.3
],
self
.
loc_loss
=
np
.
array
([[
0.1
,
0.2
,
0.3
],
[
0.3
,
0.4
,
0.1
]]).
astype
(
'float
32
'
)
[
0.3
,
0.4
,
0.1
]]).
astype
(
'float
64
'
)
self
.
match_dis
=
np
.
array
([[
0.2
,
0.4
,
0.8
],
self
.
match_dis
=
np
.
array
([[
0.2
,
0.4
,
0.8
],
[
0.1
,
0.9
,
0.3
]]).
astype
(
'float
32
'
)
[
0.1
,
0.9
,
0.3
]]).
astype
(
'float
64
'
)
self
.
match_indices
=
np
.
array
([[
0
,
-
1
,
-
1
],
self
.
match_indices
=
np
.
array
([[
0
,
-
1
,
-
1
],
[
-
1
,
0
,
-
1
]]).
astype
(
'int32'
)
[
-
1
,
0
,
-
1
]]).
astype
(
'int32'
)
...
@@ -83,10 +83,10 @@ class TestMineHardExamplesOpHardExample(TestMineHardExamplesOp):
...
@@ -83,10 +83,10 @@ class TestMineHardExamplesOpHardExample(TestMineHardExamplesOp):
self
.
sample_size
=
2
self
.
sample_size
=
2
self
.
cls_loss
=
np
.
array
([[
0.5
,
0.1
,
0.3
],
self
.
cls_loss
=
np
.
array
([[
0.5
,
0.1
,
0.3
],
[
0.3
,
0.1
,
0.1
]]).
astype
(
'float
32
'
)
[
0.3
,
0.1
,
0.1
]]).
astype
(
'float
64
'
)
self
.
loc_loss
=
np
.
array
([[
0.2
,
0.2
,
0.3
],
self
.
loc_loss
=
np
.
array
([[
0.2
,
0.2
,
0.3
],
[
0.3
,
0.1
,
0.2
]]).
astype
(
'float
32
'
)
[
0.3
,
0.1
,
0.2
]]).
astype
(
'float
64
'
)
self
.
match_indices
=
np
.
array
([[
0
,
-
1
,
-
1
],
self
.
match_indices
=
np
.
array
([[
0
,
-
1
,
-
1
],
[
-
1
,
0
,
-
1
]]).
astype
(
'int32'
)
[
-
1
,
0
,
-
1
]]).
astype
(
'int32'
)
...
...
python/paddle/fluid/tests/unittests/test_mul_op.py
浏览文件 @
642b3356
...
@@ -25,7 +25,7 @@ from paddle.fluid import Program, program_guard
...
@@ -25,7 +25,7 @@ from paddle.fluid import Program, program_guard
class
TestMulOp
(
OpTest
):
class
TestMulOp
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"mul"
self
.
op_type
=
"mul"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_dtype_type
()
self
.
init_dtype_type
()
self
.
inputs
=
{
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
2
,
5
)).
astype
(
self
.
dtype
),
'X'
:
np
.
random
.
random
((
2
,
5
)).
astype
(
self
.
dtype
),
...
@@ -69,7 +69,7 @@ class TestMulOpError(unittest.TestCase):
...
@@ -69,7 +69,7 @@ class TestMulOpError(unittest.TestCase):
class
TestMulOp2
(
OpTest
):
class
TestMulOp2
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"mul"
self
.
op_type
=
"mul"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_dtype_type
()
self
.
init_dtype_type
()
self
.
inputs
=
{
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
3
,
4
,
4
,
3
)).
astype
(
self
.
dtype
),
'X'
:
np
.
random
.
random
((
3
,
4
,
4
,
3
)).
astype
(
self
.
dtype
),
...
...
python/paddle/fluid/tests/unittests/test_multiplex_op.py
浏览文件 @
642b3356
...
@@ -26,10 +26,10 @@ class TestMultiplexOp(OpTest):
...
@@ -26,10 +26,10 @@ class TestMultiplexOp(OpTest):
index
=
np
.
arange
(
0
,
rows
).
astype
(
'int32'
)
index
=
np
.
arange
(
0
,
rows
).
astype
(
'int32'
)
np
.
random
.
shuffle
(
index
)
np
.
random
.
shuffle
(
index
)
index
=
np
.
reshape
(
index
,
(
rows
,
1
))
index
=
np
.
reshape
(
index
,
(
rows
,
1
))
ins1
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
32
"
)
ins1
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
64
"
)
ins2
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
32
"
)
ins2
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
64
"
)
ins3
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
32
"
)
ins3
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
64
"
)
ins4
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
32
"
)
ins4
=
np
.
random
.
random
((
rows
,
25
)).
astype
(
"float
64
"
)
self
.
inputs
=
{
self
.
inputs
=
{
'Ids'
:
index
,
'Ids'
:
index
,
'X'
:
[(
'x1'
,
ins1
),
(
'x2'
,
ins2
),
(
'x3'
,
ins3
),
(
'x4'
,
ins4
)]
'X'
:
[(
'x1'
,
ins1
),
(
'x2'
,
ins2
),
(
'x3'
,
ins3
),
(
'x4'
,
ins4
)]
...
...
python/paddle/fluid/tests/unittests/test_nearest_interp_op.py
浏览文件 @
642b3356
...
@@ -79,7 +79,7 @@ class TestNearestInterpOp(OpTest):
...
@@ -79,7 +79,7 @@ class TestNearestInterpOp(OpTest):
self
.
data_layout
=
'NCHW'
self
.
data_layout
=
'NCHW'
self
.
init_test_case
()
self
.
init_test_case
()
self
.
op_type
=
"nearest_interp"
self
.
op_type
=
"nearest_interp"
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
32
"
)
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
64
"
)
if
self
.
data_layout
==
"NCHW"
:
if
self
.
data_layout
==
"NCHW"
:
in_h
=
self
.
input_shape
[
2
]
in_h
=
self
.
input_shape
[
2
]
...
@@ -340,11 +340,11 @@ class TestNearestInterpOp_attr_tensor(OpTest):
...
@@ -340,11 +340,11 @@ class TestNearestInterpOp_attr_tensor(OpTest):
'align_corners'
:
self
.
align_corners
,
'align_corners'
:
self
.
align_corners
,
}
}
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
32
"
)
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
64
"
)
self
.
inputs
=
{
'X'
:
input_np
}
self
.
inputs
=
{
'X'
:
input_np
}
if
self
.
scale_by_1Dtensor
:
if
self
.
scale_by_1Dtensor
:
self
.
inputs
[
'Scale'
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float
32
"
)
self
.
inputs
[
'Scale'
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float
64
"
)
elif
self
.
scale
>
0
:
elif
self
.
scale
>
0
:
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
)
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
)
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
)
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
)
...
...
python/paddle/fluid/tests/unittests/test_pixel_shuffle.py
浏览文件 @
642b3356
...
@@ -25,7 +25,7 @@ class TestPixelShuffle(OpTest):
...
@@ -25,7 +25,7 @@ class TestPixelShuffle(OpTest):
n
,
c
,
h
,
w
=
2
,
9
,
4
,
4
n
,
c
,
h
,
w
=
2
,
9
,
4
,
4
up_factor
=
3
up_factor
=
3
shape
=
[
n
,
c
,
h
,
w
]
shape
=
[
n
,
c
,
h
,
w
]
x
=
np
.
random
.
random
(
shape
).
astype
(
"float
32
"
)
x
=
np
.
random
.
random
(
shape
).
astype
(
"float
64
"
)
new_shape
=
(
n
,
c
//
(
up_factor
*
up_factor
),
up_factor
,
up_factor
,
h
,
new_shape
=
(
n
,
c
//
(
up_factor
*
up_factor
),
up_factor
,
up_factor
,
h
,
w
)
w
)
# reshape to (num,output_channel,upscale_factor,upscale_factor,h,w)
# reshape to (num,output_channel,upscale_factor,upscale_factor,h,w)
...
...
python/paddle/fluid/tests/unittests/test_pool2d_op.py
浏览文件 @
642b3356
...
@@ -39,7 +39,7 @@ def max_pool2D_forward_naive(x,
...
@@ -39,7 +39,7 @@ def max_pool2D_forward_naive(x,
ceil_mode
=
False
,
ceil_mode
=
False
,
exclusive
=
True
,
exclusive
=
True
,
adaptive
=
False
,
adaptive
=
False
,
data_type
=
np
.
float
32
):
data_type
=
np
.
float
64
):
N
,
C
,
H
,
W
=
x
.
shape
N
,
C
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
if
global_pool
==
1
:
ksize
=
[
H
,
W
]
ksize
=
[
H
,
W
]
...
@@ -79,7 +79,7 @@ def avg_pool2D_forward_naive(x,
...
@@ -79,7 +79,7 @@ def avg_pool2D_forward_naive(x,
ceil_mode
=
False
,
ceil_mode
=
False
,
exclusive
=
True
,
exclusive
=
True
,
adaptive
=
False
,
adaptive
=
False
,
data_type
=
np
.
float
32
):
data_type
=
np
.
float
64
):
N
,
C
,
H
,
W
=
x
.
shape
N
,
C
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
if
global_pool
==
1
:
ksize
=
[
H
,
W
]
ksize
=
[
H
,
W
]
...
@@ -320,7 +320,7 @@ class TestPool2D_Op(OpTest):
...
@@ -320,7 +320,7 @@ class TestPool2D_Op(OpTest):
self
.
use_cudnn
=
False
self
.
use_cudnn
=
False
def
init_data_type
(
self
):
def
init_data_type
(
self
):
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
init_pool_type
(
self
):
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool_type
=
"avg"
...
...
python/paddle/fluid/tests/unittests/test_pool3d_op.py
浏览文件 @
642b3356
...
@@ -209,7 +209,7 @@ class TestPool3d_Op(OpTest):
...
@@ -209,7 +209,7 @@ class TestPool3d_Op(OpTest):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"pool3d"
self
.
op_type
=
"pool3d"
self
.
init_kernel_type
()
self
.
init_kernel_type
()
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_test_case
()
self
.
init_test_case
()
self
.
padding_algorithm
=
"EXPLICIT"
self
.
padding_algorithm
=
"EXPLICIT"
self
.
init_paddings
()
self
.
init_paddings
()
...
...
python/paddle/fluid/tests/unittests/test_pool_max_op.py
浏览文件 @
642b3356
...
@@ -140,11 +140,11 @@ class TestMaxPoolWithIndex_Op(OpTest):
...
@@ -140,11 +140,11 @@ class TestMaxPoolWithIndex_Op(OpTest):
self
.
init_global
()
self
.
init_global
()
self
.
init_adaptive
()
self
.
init_adaptive
()
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
32
"
)
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
64
"
)
output
,
mask
=
self
.
pool_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
output
,
mask
=
self
.
pool_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
self
.
paddings
,
self
.
global_pool
,
self
.
paddings
,
self
.
global_pool
,
self
.
adaptive
)
self
.
adaptive
)
output
=
output
.
astype
(
"float
32
"
)
output
=
output
.
astype
(
"float
64
"
)
mask
=
mask
.
astype
(
"int32"
)
mask
=
mask
.
astype
(
"int32"
)
self
.
attrs
=
{
self
.
attrs
=
{
...
...
python/paddle/fluid/tests/unittests/test_psroi_pool_op.py
浏览文件 @
642b3356
...
@@ -47,7 +47,7 @@ class TestPSROIPoolOp(OpTest):
...
@@ -47,7 +47,7 @@ class TestPSROIPoolOp(OpTest):
self
.
pooled_height
=
2
self
.
pooled_height
=
2
self
.
pooled_width
=
2
self
.
pooled_width
=
2
self
.
x
=
np
.
random
.
random
(
self
.
x_dim
).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
(
self
.
x_dim
).
astype
(
'float
64
'
)
def
make_rois
(
self
):
def
make_rois
(
self
):
rois
=
[]
rois
=
[]
...
@@ -67,7 +67,7 @@ class TestPSROIPoolOp(OpTest):
...
@@ -67,7 +67,7 @@ class TestPSROIPoolOp(OpTest):
roi
=
[
bno
,
x1
,
y1
,
x2
,
y2
]
roi
=
[
bno
,
x1
,
y1
,
x2
,
y2
]
rois
.
append
(
roi
)
rois
.
append
(
roi
)
self
.
rois_num
=
len
(
rois
)
self
.
rois_num
=
len
(
rois
)
self
.
rois
=
np
.
array
(
rois
).
astype
(
'float
32
'
)
self
.
rois
=
np
.
array
(
rois
).
astype
(
'float
64
'
)
def
calc_psroi_pool
(
self
):
def
calc_psroi_pool
(
self
):
output_shape
=
(
self
.
rois_num
,
self
.
output_channels
,
self
.
pooled_height
,
output_shape
=
(
self
.
rois_num
,
self
.
output_channels
,
self
.
pooled_height
,
...
@@ -117,7 +117,7 @@ class TestPSROIPoolOp(OpTest):
...
@@ -117,7 +117,7 @@ class TestPSROIPoolOp(OpTest):
bin_area
=
(
hend
-
hstart
)
*
(
wend
-
wstart
)
bin_area
=
(
hend
-
hstart
)
*
(
wend
-
wstart
)
out_data
[
i
,
c
,
ph
,
pw
]
=
0.
if
is_empty
else
(
out_data
[
i
,
c
,
ph
,
pw
]
=
0.
if
is_empty
else
(
out_sum
/
float
(
bin_area
))
out_sum
/
float
(
bin_area
))
self
.
outs
=
out_data
.
astype
(
'float
32
'
)
self
.
outs
=
out_data
.
astype
(
'float
64
'
)
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
'psroi_pool'
self
.
op_type
=
'psroi_pool'
...
...
python/paddle/fluid/tests/unittests/test_reverse_op.py
浏览文件 @
642b3356
...
@@ -21,7 +21,7 @@ from op_test import OpTest
...
@@ -21,7 +21,7 @@ from op_test import OpTest
class
TestReverseOp
(
OpTest
):
class
TestReverseOp
(
OpTest
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
x
=
np
.
random
.
random
((
3
,
40
)).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
((
3
,
40
)).
astype
(
'float
64
'
)
self
.
axis
=
[
0
]
self
.
axis
=
[
0
]
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -43,25 +43,25 @@ class TestReverseOp(OpTest):
...
@@ -43,25 +43,25 @@ class TestReverseOp(OpTest):
class
TestCase0
(
TestReverseOp
):
class
TestCase0
(
TestReverseOp
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
x
=
np
.
random
.
random
((
3
,
40
)).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
((
3
,
40
)).
astype
(
'float
64
'
)
self
.
axis
=
[
1
]
self
.
axis
=
[
1
]
class
TestCase1
(
TestReverseOp
):
class
TestCase1
(
TestReverseOp
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
x
=
np
.
random
.
random
((
3
,
40
)).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
((
3
,
40
)).
astype
(
'float
64
'
)
self
.
axis
=
[
0
,
1
]
self
.
axis
=
[
0
,
1
]
class
TestCase2
(
TestReverseOp
):
class
TestCase2
(
TestReverseOp
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
x
=
np
.
random
.
random
((
3
,
4
,
10
)).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
((
3
,
4
,
10
)).
astype
(
'float
64
'
)
self
.
axis
=
[
0
,
2
]
self
.
axis
=
[
0
,
2
]
class
TestCase3
(
TestReverseOp
):
class
TestCase3
(
TestReverseOp
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
x
=
np
.
random
.
random
((
3
,
4
,
10
)).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
((
3
,
4
,
10
)).
astype
(
'float
64
'
)
self
.
axis
=
[
1
,
2
]
self
.
axis
=
[
1
,
2
]
...
...
python/paddle/fluid/tests/unittests/test_roi_align_op.py
浏览文件 @
642b3356
...
@@ -50,16 +50,16 @@ class TestROIAlignOp(OpTest):
...
@@ -50,16 +50,16 @@ class TestROIAlignOp(OpTest):
self
.
pooled_width
=
2
self
.
pooled_width
=
2
self
.
sampling_ratio
=
-
1
self
.
sampling_ratio
=
-
1
self
.
x
=
np
.
random
.
random
(
self
.
x_dim
).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
(
self
.
x_dim
).
astype
(
'float
64
'
)
def
pre_calc
(
self
,
x_i
,
roi_xmin
,
roi_ymin
,
roi_bin_grid_h
,
roi_bin_grid_w
,
def
pre_calc
(
self
,
x_i
,
roi_xmin
,
roi_ymin
,
roi_bin_grid_h
,
roi_bin_grid_w
,
bin_size_h
,
bin_size_w
):
bin_size_h
,
bin_size_w
):
count
=
roi_bin_grid_h
*
roi_bin_grid_w
count
=
roi_bin_grid_h
*
roi_bin_grid_w
bilinear_pos
=
np
.
zeros
(
bilinear_pos
=
np
.
zeros
(
[
self
.
channels
,
self
.
pooled_height
,
self
.
pooled_width
,
count
,
4
],
[
self
.
channels
,
self
.
pooled_height
,
self
.
pooled_width
,
count
,
4
],
np
.
float
32
)
np
.
float
64
)
bilinear_w
=
np
.
zeros
(
bilinear_w
=
np
.
zeros
(
[
self
.
pooled_height
,
self
.
pooled_width
,
count
,
4
],
np
.
float
32
)
[
self
.
pooled_height
,
self
.
pooled_width
,
count
,
4
],
np
.
float
64
)
for
ph
in
range
(
self
.
pooled_width
):
for
ph
in
range
(
self
.
pooled_width
):
for
pw
in
range
(
self
.
pooled_height
):
for
pw
in
range
(
self
.
pooled_height
):
c
=
0
c
=
0
...
@@ -109,7 +109,7 @@ class TestROIAlignOp(OpTest):
...
@@ -109,7 +109,7 @@ class TestROIAlignOp(OpTest):
def
calc_roi_align
(
self
):
def
calc_roi_align
(
self
):
self
.
out_data
=
np
.
zeros
(
self
.
out_data
=
np
.
zeros
(
(
self
.
rois_num
,
self
.
channels
,
self
.
pooled_height
,
(
self
.
rois_num
,
self
.
channels
,
self
.
pooled_height
,
self
.
pooled_width
)).
astype
(
'float
32
'
)
self
.
pooled_width
)).
astype
(
'float
64
'
)
for
i
in
range
(
self
.
rois_num
):
for
i
in
range
(
self
.
rois_num
):
roi
=
self
.
rois
[
i
]
roi
=
self
.
rois
[
i
]
...
@@ -157,7 +157,7 @@ class TestROIAlignOp(OpTest):
...
@@ -157,7 +157,7 @@ class TestROIAlignOp(OpTest):
roi
=
[
bno
,
x1
,
y1
,
x2
,
y2
]
roi
=
[
bno
,
x1
,
y1
,
x2
,
y2
]
rois
.
append
(
roi
)
rois
.
append
(
roi
)
self
.
rois_num
=
len
(
rois
)
self
.
rois_num
=
len
(
rois
)
self
.
rois
=
np
.
array
(
rois
).
astype
(
"float
32
"
)
self
.
rois
=
np
.
array
(
rois
).
astype
(
"float
64
"
)
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"roi_align"
self
.
op_type
=
"roi_align"
...
...
python/paddle/fluid/tests/unittests/test_roi_pool_op.py
浏览文件 @
642b3356
...
@@ -51,7 +51,7 @@ class TestROIPoolOp(OpTest):
...
@@ -51,7 +51,7 @@ class TestROIPoolOp(OpTest):
self
.
pooled_height
=
2
self
.
pooled_height
=
2
self
.
pooled_width
=
2
self
.
pooled_width
=
2
self
.
x
=
np
.
random
.
random
(
self
.
x_dim
).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
(
self
.
x_dim
).
astype
(
'float
64
'
)
def
calc_roi_pool
(
self
):
def
calc_roi_pool
(
self
):
out_data
=
np
.
zeros
((
self
.
rois_num
,
self
.
channels
,
self
.
pooled_height
,
out_data
=
np
.
zeros
((
self
.
rois_num
,
self
.
channels
,
self
.
pooled_height
,
...
@@ -103,7 +103,7 @@ class TestROIPoolOp(OpTest):
...
@@ -103,7 +103,7 @@ class TestROIPoolOp(OpTest):
argmax_data
[
i
,
c
,
ph
,
argmax_data
[
i
,
c
,
ph
,
pw
]
=
h
*
self
.
width
+
w
pw
]
=
h
*
self
.
width
+
w
self
.
outs
=
out_data
.
astype
(
'float
32
'
)
self
.
outs
=
out_data
.
astype
(
'float
64
'
)
self
.
argmaxes
=
argmax_data
.
astype
(
'int64'
)
self
.
argmaxes
=
argmax_data
.
astype
(
'int64'
)
def
make_rois
(
self
):
def
make_rois
(
self
):
...
@@ -125,7 +125,7 @@ class TestROIPoolOp(OpTest):
...
@@ -125,7 +125,7 @@ class TestROIPoolOp(OpTest):
roi
=
[
bno
,
x1
,
y1
,
x2
,
y2
]
roi
=
[
bno
,
x1
,
y1
,
x2
,
y2
]
rois
.
append
(
roi
)
rois
.
append
(
roi
)
self
.
rois_num
=
len
(
rois
)
self
.
rois_num
=
len
(
rois
)
self
.
rois
=
np
.
array
(
rois
).
astype
(
"float
32
"
)
self
.
rois
=
np
.
array
(
rois
).
astype
(
"float
64
"
)
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"roi_pool"
self
.
op_type
=
"roi_pool"
...
...
python/paddle/fluid/tests/unittests/test_scatter_nd_op.py
浏览文件 @
642b3356
...
@@ -66,9 +66,9 @@ class TestScatterNdAddSimpleOp(OpTest):
...
@@ -66,9 +66,9 @@ class TestScatterNdAddSimpleOp(OpTest):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"scatter_nd_add"
self
.
op_type
=
"scatter_nd_add"
#ref_np = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8]).astype("float32")
#ref_np = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8]).astype("float32")
ref_np
=
np
.
random
.
random
([
100
]).
astype
(
"float
32
"
)
ref_np
=
np
.
random
.
random
([
100
]).
astype
(
"float
64
"
)
index_np
=
np
.
random
.
randint
(
0
,
100
,
[
100
,
1
]).
astype
(
"int32"
)
index_np
=
np
.
random
.
randint
(
0
,
100
,
[
100
,
1
]).
astype
(
"int32"
)
updates_np
=
np
.
random
.
random
([
100
]).
astype
(
"float
32
"
)
updates_np
=
np
.
random
.
random
([
100
]).
astype
(
"float
64
"
)
expect_np
=
numpy_scatter_nd_add
(
ref_np
.
copy
(),
index_np
,
updates_np
)
expect_np
=
numpy_scatter_nd_add
(
ref_np
.
copy
(),
index_np
,
updates_np
)
#expect_np = [ 0. 23. 12. 14. 4. 17. 6. 7. 8.]
#expect_np = [ 0. 23. 12. 14. 4. 17. 6. 7. 8.]
...
@@ -89,10 +89,10 @@ class TestScatterNdAddWithEmptyIndex(OpTest):
...
@@ -89,10 +89,10 @@ class TestScatterNdAddWithEmptyIndex(OpTest):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"scatter_nd_add"
self
.
op_type
=
"scatter_nd_add"
ref_np
=
np
.
array
([[
65
,
17
],
[
-
14
,
-
25
]]).
astype
(
"float
32
"
)
ref_np
=
np
.
array
([[
65
,
17
],
[
-
14
,
-
25
]]).
astype
(
"float
64
"
)
index_np
=
np
.
array
([[],
[]]).
astype
(
"int32"
)
index_np
=
np
.
array
([[],
[]]).
astype
(
"int32"
)
updates_np
=
np
.
array
([[[
-
1
,
-
2
],
[
1
,
2
]],
updates_np
=
np
.
array
([[[
-
1
,
-
2
],
[
1
,
2
]],
[[
3
,
4
],
[
-
3
,
-
4
]]]).
astype
(
"float
32
"
)
[[
3
,
4
],
[
-
3
,
-
4
]]]).
astype
(
"float
64
"
)
expect_np
=
numpy_scatter_nd_add
(
ref_np
.
copy
(),
index_np
,
updates_np
)
expect_np
=
numpy_scatter_nd_add
(
ref_np
.
copy
(),
index_np
,
updates_np
)
#expect_np = [[67, 19], [-16, -27]]
#expect_np = [[67, 19], [-16, -27]]
...
@@ -115,12 +115,12 @@ class TestScatterNdAddWithHighRankSame(OpTest):
...
@@ -115,12 +115,12 @@ class TestScatterNdAddWithHighRankSame(OpTest):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"scatter_nd_add"
self
.
op_type
=
"scatter_nd_add"
shape
=
(
10
,
9
,
8
,
1
,
15
)
shape
=
(
10
,
9
,
8
,
1
,
15
)
ref_np
=
np
.
random
.
rand
(
*
shape
).
astype
(
"float
32
"
)
ref_np
=
np
.
random
.
rand
(
*
shape
).
astype
(
"float
64
"
)
index_np
=
np
.
vstack
(
index_np
=
np
.
vstack
(
[
np
.
random
.
randint
(
[
np
.
random
.
randint
(
0
,
s
,
size
=
150
)
for
s
in
shape
]).
T
.
astype
(
"int32"
)
0
,
s
,
size
=
150
)
for
s
in
shape
]).
T
.
astype
(
"int32"
)
update_shape
=
judge_update_shape
(
ref_np
,
index_np
)
update_shape
=
judge_update_shape
(
ref_np
,
index_np
)
updates_np
=
np
.
random
.
rand
(
*
update_shape
).
astype
(
"float
32
"
)
updates_np
=
np
.
random
.
rand
(
*
update_shape
).
astype
(
"float
64
"
)
expect_np
=
numpy_scatter_nd_add
(
ref_np
.
copy
(),
index_np
,
updates_np
)
expect_np
=
numpy_scatter_nd_add
(
ref_np
.
copy
(),
index_np
,
updates_np
)
self
.
inputs
=
{
'X'
:
ref_np
,
'Index'
:
index_np
,
'Updates'
:
updates_np
}
self
.
inputs
=
{
'X'
:
ref_np
,
'Index'
:
index_np
,
'Updates'
:
updates_np
}
...
...
python/paddle/fluid/tests/unittests/test_selu_op.py
浏览文件 @
642b3356
...
@@ -24,7 +24,7 @@ class SeluTest(OpTest):
...
@@ -24,7 +24,7 @@ class SeluTest(OpTest):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"selu"
self
.
op_type
=
"selu"
self
.
x_shape
=
[
3
,
5
,
5
,
10
]
self
.
x_shape
=
[
3
,
5
,
5
,
10
]
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_x_shape
()
self
.
init_x_shape
()
self
.
init_dtype
()
self
.
init_dtype
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录