Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
f4379a91
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f4379a91
编写于
12月 20, 2019
作者:
J
juncaipeng
提交者:
Tao Luo
12月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update the precision of some op tests from fp32 to fp64 (#21847)
上级
538c8489
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
102 addition
and
102 deletion
+102
-102
python/paddle/fluid/tests/unittests/test_sequence_concat.py
python/paddle/fluid/tests/unittests/test_sequence_concat.py
+2
-2
python/paddle/fluid/tests/unittests/test_sequence_expand.py
python/paddle/fluid/tests/unittests/test_sequence_expand.py
+14
-14
python/paddle/fluid/tests/unittests/test_sequence_expand_as.py
...n/paddle/fluid/tests/unittests/test_sequence_expand_as.py
+8
-8
python/paddle/fluid/tests/unittests/test_sequence_pad_op.py
python/paddle/fluid/tests/unittests/test_sequence_pad_op.py
+8
-8
python/paddle/fluid/tests/unittests/test_sequence_reshape.py
python/paddle/fluid/tests/unittests/test_sequence_reshape.py
+6
-6
python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py
.../paddle/fluid/tests/unittests/test_sequence_scatter_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py
.../paddle/fluid/tests/unittests/test_sequence_softmax_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py
...on/paddle/fluid/tests/unittests/test_sequence_unpad_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py
...ts/unittests/test_sigmoid_cross_entropy_with_logits_op.py
+14
-14
python/paddle/fluid/tests/unittests/test_sigmoid_focal_loss_op.py
...addle/fluid/tests/unittests/test_sigmoid_focal_loss_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_sign_op.py
python/paddle/fluid/tests/unittests/test_sign_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_slice_op.py
python/paddle/fluid/tests/unittests/test_slice_op.py
+18
-18
python/paddle/fluid/tests/unittests/test_softmax_op.py
python/paddle/fluid/tests/unittests/test_softmax_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py
...uid/tests/unittests/test_softmax_with_cross_entropy_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_space_to_depth_op.py
...on/paddle/fluid/tests/unittests/test_space_to_depth_op.py
+8
-8
python/paddle/fluid/tests/unittests/test_spectral_norm_op.py
python/paddle/fluid/tests/unittests/test_spectral_norm_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_split_op.py
python/paddle/fluid/tests/unittests/test_split_op.py
+5
-5
python/paddle/fluid/tests/unittests/test_spp_op.py
python/paddle/fluid/tests/unittests/test_spp_op.py
+3
-3
未找到文件。
python/paddle/fluid/tests/unittests/test_sequence_concat.py
浏览文件 @
f4379a91
...
...
@@ -26,8 +26,8 @@ class TestSequenceConcat(OpTest):
self
.
out_lod
=
[
19
,
11
]
def
setUp
(
self
):
x1
=
np
.
random
.
random
(
size
=
(
10
,
80
)).
astype
(
'float
32
'
)
x2
=
np
.
random
.
random
(
size
=
(
20
,
80
)).
astype
(
'float
32
'
)
x1
=
np
.
random
.
random
(
size
=
(
10
,
80
)).
astype
(
'float
64
'
)
x2
=
np
.
random
.
random
(
size
=
(
20
,
80
)).
astype
(
'float
64
'
)
self
.
setLoD
()
out
=
np
.
concatenate
((
x1
[
0
:
self
.
lod1
[
0
]],
x2
[
0
:
self
.
lod2
[
0
]],
...
...
python/paddle/fluid/tests/unittests/test_sequence_expand.py
浏览文件 @
f4379a91
...
...
@@ -21,8 +21,8 @@ from op_test import OpTest
class
TestSequenceExpand
(
OpTest
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
40
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
40
]).
astype
(
'float
64
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
1
,
3
,
4
]]
self
.
inputs
=
{
'X'
:
x_data
,
'Y'
:
(
y_data
,
y_lod
)}
...
...
@@ -80,8 +80,8 @@ class TestSequenceExpand(OpTest):
class
TestSequenceExpandCase1
(
TestSequenceExpand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
64
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
2
,
3
],
[
2
,
2
,
3
,
3
,
3
]]
self
.
inputs
=
{
'X'
:
x_data
,
'Y'
:
(
y_data
,
y_lod
)}
self
.
attrs
=
{
'ref_level'
:
1
}
...
...
@@ -89,9 +89,9 @@ class TestSequenceExpandCase1(TestSequenceExpand):
class
TestSequenceExpandCase2
(
TestSequenceExpand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
2
,
2
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
2
,
2
]).
astype
(
'float
64
'
)
x_lod
=
[[
1
]]
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
2
,
2
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
2
,
2
]).
astype
(
'float
64
'
)
y_lod
=
[[
2
],
[
1
,
1
]]
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
self
.
attrs
=
{
'ref_level'
:
0
}
...
...
@@ -99,9 +99,9 @@ class TestSequenceExpandCase2(TestSequenceExpand):
class
TestSequenceExpandCase3
(
TestSequenceExpand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
4
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
4
,
1
]).
astype
(
'float
64
'
)
x_lod
=
[[
1
,
1
,
1
,
1
]]
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
2
,
2
,
2
,
2
]]
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
...
...
@@ -109,17 +109,17 @@ class TestSequenceExpandCase3(TestSequenceExpand):
class
TestSequenceExpandCase4
(
TestSequenceExpand
):
def
set_data
(
self
):
data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
*
2
,
1
])
x_data
=
np
.
array
(
data
).
reshape
([
5
,
2
]).
astype
(
'float
32
'
)
x_data
=
np
.
array
(
data
).
reshape
([
5
,
2
]).
astype
(
'float
64
'
)
x_lod
=
[[
2
,
3
]]
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
2
],
[
2
,
3
]]
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
class
TestSequenceExpandCase5
(
TestSequenceExpand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
6
,
1
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
6
,
1
]).
astype
(
'float
64
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
2
,
4
],
[
2
,
2
,
3
,
0
,
3
,
3
]]
self
.
inputs
=
{
'X'
:
x_data
,
'Y'
:
(
y_data
,
y_lod
)}
self
.
attrs
=
{
'ref_level'
:
1
}
...
...
@@ -127,9 +127,9 @@ class TestSequenceExpandCase5(TestSequenceExpand):
class
TestSequenceExpandCase6
(
TestSequenceExpand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
4
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
4
,
1
]).
astype
(
'float
64
'
)
x_lod
=
[[
1
,
1
,
0
,
1
,
1
]]
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
0
,
2
,
4
,
2
,
0
]]
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
...
...
python/paddle/fluid/tests/unittests/test_sequence_expand_as.py
浏览文件 @
f4379a91
...
...
@@ -26,8 +26,8 @@ class TestSequenceExpandAs(OpTest):
self
.
compute
()
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
40
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
40
]).
astype
(
'float
64
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
1
,
3
,
4
]]
self
.
inputs
=
{
'X'
:
x_data
,
'Y'
:
(
y_data
,
y_lod
)}
...
...
@@ -57,27 +57,27 @@ class TestSequenceExpandAs(OpTest):
class
TestSequenceExpandAsCase1
(
TestSequenceExpandAs
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
64
'
)
x_lod
=
[[
2
,
3
]]
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
1
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
2
,
2
,
0
,
3
,
3
]]
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
class
TestSequenceExpandAsCase2
(
TestSequenceExpandAs
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float
64
'
)
x_lod
=
[[
2
,
3
]]
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
1
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
1
]).
astype
(
'float
64
'
)
y_lod
=
[[
0
,
4
,
0
,
6
,
0
]]
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
class
TestSequenceExpandAsCase3
(
TestSequenceExpandAs
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
2
,
2
]).
astype
(
'float
32
'
)
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
2
,
2
]).
astype
(
'float
64
'
)
x_lod
=
[[
1
]]
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
2
,
2
]).
astype
(
'float
32
'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
2
,
2
]).
astype
(
'float
64
'
)
y_lod
=
[[
2
]]
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
...
...
python/paddle/fluid/tests/unittests/test_sequence_pad_op.py
浏览文件 @
f4379a91
...
...
@@ -23,7 +23,7 @@ class TestSequencePadOp(OpTest):
self
.
x_len_lod
=
[[
2
,
3
,
4
,
3
]]
self
.
pad_value
=
[
1.0
]
self
.
padded_length
=
-
1
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
0.5
,
self
.
x_shape
).
astype
(
self
.
dtype
)
...
...
@@ -84,7 +84,7 @@ class TestSequencePadOp2(TestSequencePadOp):
self
.
x_len_lod
=
[[
2
,
3
,
4
,
3
]]
self
.
pad_value
=
[
1.0
,
2.0
,
3.0
,
4.0
]
self
.
padded_length
=
-
1
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestSequencePadOp3
(
TestSequencePadOp
):
...
...
@@ -93,7 +93,7 @@ class TestSequencePadOp3(TestSequencePadOp):
self
.
x_len_lod
=
[[
2
,
3
,
4
,
3
]]
self
.
pad_value
=
[
1.0
]
self
.
padded_length
=
7
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestSequencePadOp4
(
TestSequencePadOp
):
...
...
@@ -102,7 +102,7 @@ class TestSequencePadOp4(TestSequencePadOp):
self
.
x_len_lod
=
[[
2
,
3
,
4
,
3
]]
self
.
pad_value
=
[
1.0
,
2.0
,
3.0
,
4.0
]
self
.
padded_length
=
7
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestSequencePadOp5
(
TestSequencePadOp
):
...
...
@@ -111,7 +111,7 @@ class TestSequencePadOp5(TestSequencePadOp):
self
.
x_len_lod
=
[[
2
,
3
,
4
,
3
]]
self
.
pad_value
=
[
1.0
]
self
.
padded_length
=
-
1
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestSequencePadOp6
(
TestSequencePadOp
):
...
...
@@ -120,7 +120,7 @@ class TestSequencePadOp6(TestSequencePadOp):
self
.
x_len_lod
=
[[
2
,
3
,
4
,
3
]]
self
.
pad_value
=
[[
1.0
,
2.0
],
[
3.0
,
4.0
]]
self
.
padded_length
=
-
1
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestSequencePadOp7
(
TestSequencePadOp
):
...
...
@@ -129,7 +129,7 @@ class TestSequencePadOp7(TestSequencePadOp):
self
.
x_len_lod
=
[[
2
,
3
,
4
,
3
]]
self
.
pad_value
=
[
1.0
]
self
.
padded_length
=
7
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestSequencePadOp8
(
TestSequencePadOp
):
...
...
@@ -138,7 +138,7 @@ class TestSequencePadOp8(TestSequencePadOp):
self
.
x_len_lod
=
[[
0
,
8
,
0
,
4
,
0
]]
self
.
pad_value
=
[
1.0
]
self
.
padded_length
=
10
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_sequence_reshape.py
浏览文件 @
f4379a91
...
...
@@ -24,7 +24,7 @@ class TestSequenceReshape(OpTest):
def
init_data
(
self
):
self
.
dimension
=
12
self
.
x_lod
=
[[
4
,
1
,
3
,
3
]]
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
11
,
24
]).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
11
,
24
]).
astype
(
'float
64
'
)
def
setUp
(
self
):
self
.
init_data
()
...
...
@@ -42,7 +42,7 @@ class TestSequenceReshape(OpTest):
offset
=
(
seq_len
*
x_width
)
/
dimension
assert
int
(
offset
)
*
dimension
==
seq_len
*
x_width
out_lod
[
0
].
append
(
int
(
offset
))
out
=
np
.
zeros
(
shape
=
(
sum
(
out_lod
[
0
]),
dimension
)).
astype
(
'float
32
'
)
out
=
np
.
zeros
(
shape
=
(
sum
(
out_lod
[
0
]),
dimension
)).
astype
(
'float
64
'
)
out
.
ravel
()[:]
=
x
.
ravel
()[:]
return
out
,
out_lod
...
...
@@ -57,28 +57,28 @@ class TestSequenceReshape_reduce(TestSequenceReshape):
def
init_data
(
self
):
self
.
dimension
=
24
self
.
x_lod
=
[[
4
,
2
,
2
,
4
]]
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
64
'
)
class
TestSequenceReshape_same
(
TestSequenceReshape
):
def
init_data
(
self
):
self
.
dimension
=
12
self
.
x_lod
=
[[
4
,
2
,
2
,
4
]]
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
64
'
)
class
TestSequenceReshape_reduce_seq_len0
(
TestSequenceReshape
):
def
init_data
(
self
):
self
.
dimension
=
24
self
.
x_lod
=
[[
0
,
6
,
0
,
2
,
4
]]
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
64
'
)
class
TestSequenceReshape_reduce_seq_len0_case1
(
TestSequenceReshape
):
def
init_data
(
self
):
self
.
dimension
=
24
self
.
x_lod
=
[[
0
,
2
,
8
,
2
,
0
]]
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
12
,
12
]).
astype
(
'float
64
'
)
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py
浏览文件 @
f4379a91
...
...
@@ -24,12 +24,12 @@ class TestSequenceScatterOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"sequence_scatter"
X_data
=
np
.
random
.
uniform
(
0.1
,
1.0
,
[
3
,
6
]).
astype
(
'float
32
'
)
X_data
=
np
.
random
.
uniform
(
0.1
,
1.0
,
[
3
,
6
]).
astype
(
'float
64
'
)
Ids_data
=
np
.
array
([[
0
],
[
1
],
[
2
],
[
5
],
[
4
],
[
3
],
[
0
],
[
1
],
[
3
],
[
2
],
[
5
],
[
4
]]).
astype
(
'int64'
)
Ids_lod
=
self
.
init_lod
()
Updates_data
=
np
.
random
.
uniform
(
0.1
,
1.0
,
[
12
,
1
]).
astype
(
'float
32
'
)
Updates_data
=
np
.
random
.
uniform
(
0.1
,
1.0
,
[
12
,
1
]).
astype
(
'float
64
'
)
Updates_lod
=
Ids_lod
Out_data
=
np
.
copy
(
X_data
)
...
...
python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py
浏览文件 @
f4379a91
...
...
@@ -27,9 +27,9 @@ class TestSequenceSoftmaxOp(OpTest):
self
.
use_cudnn
=
False
self
.
init_op_type
()
x
=
np
.
random
.
uniform
(
0.1
,
1
,
(
110
,
1
)).
astype
(
"float
32
"
)
x
=
np
.
random
.
uniform
(
0.1
,
1
,
(
110
,
1
)).
astype
(
"float
64
"
)
self
.
init_lod
()
out
=
np
.
zeros
((
110
,
1
)).
astype
(
"float
32
"
)
out
=
np
.
zeros
((
110
,
1
)).
astype
(
"float
64
"
)
offset
=
0
for
i
in
range
(
len
(
self
.
lod
[
0
])):
if
(
self
.
lod
[
0
][
i
]
==
0
):
...
...
python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py
浏览文件 @
f4379a91
...
...
@@ -22,7 +22,7 @@ class TestSequenceUnpadOp(OpTest):
def
init
(
self
):
self
.
length
=
[
2
,
3
,
4
]
self
.
x_shape
=
(
3
,
40
)
self
.
dtype
=
"float
32
"
self
.
dtype
=
"float
64
"
def
compute
(
self
):
assert
len
(
self
.
length
)
==
self
.
x_shape
[
0
]
...
...
@@ -58,7 +58,7 @@ class TestSequenceUnpadOp2(TestSequenceUnpadOp):
def
init
(
self
):
self
.
length
=
[
2
,
3
,
4
]
self
.
x_shape
=
(
3
,
5
,
4
,
3
)
self
.
dtype
=
"float
32
"
self
.
dtype
=
"float
64
"
class
TestSequenceUnpadOp3
(
TestSequenceUnpadOp
):
...
...
python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py
浏览文件 @
f4379a91
...
...
@@ -33,9 +33,9 @@ class TestSigmoidCrossEntropyWithLogitsOp1(OpTest):
self
.
inputs
=
{
'X'
:
logit
(
np
.
random
.
uniform
(
0
,
1
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)),
.
astype
(
"float
64
"
)),
'Label'
:
np
.
random
.
randint
(
0
,
2
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
# Fw Pass is implemented as elementwise sigmoid followed by
...
...
@@ -65,9 +65,9 @@ class TestSigmoidCrossEntropyWithLogitsOp2(OpTest):
self
.
inputs
=
{
'X'
:
logit
(
np
.
random
.
uniform
(
0
,
1
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)),
.
astype
(
"float
64
"
)),
'Label'
:
np
.
random
.
randint
(
-
1
,
2
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
self
.
attrs
=
{
'ignore_index'
:
ignore_index
,
}
# Fw Pass is implemented as elementwise sigmoid followed by
...
...
@@ -98,9 +98,9 @@ class TestSigmoidCrossEntropyWithLogitsOp3(OpTest):
self
.
inputs
=
{
'X'
:
logit
(
np
.
random
.
uniform
(
0
,
1
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)),
.
astype
(
"float
64
"
)),
'Label'
:
np
.
random
.
uniform
(
0
,
1
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
# Fw Pass is implemented as elementwise sigmoid followed by
...
...
@@ -127,9 +127,9 @@ class TestSigmoidCrossEntropyWithNorm(OpTest):
self
.
inputs
=
{
'X'
:
logit
(
np
.
random
.
uniform
(
0
,
1
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)),
.
astype
(
"float
64
"
)),
'Label'
:
np
.
random
.
randint
(
-
1
,
2
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
self
.
attrs
=
{
'ignore_index'
:
ignore_index
,
'normalize'
:
True
}
sigmoid_X
=
expit
(
self
.
inputs
[
'X'
])
...
...
@@ -160,9 +160,9 @@ class TestSigmoidCrossEntropyWithLogitsOp5(OpTest):
self
.
inputs
=
{
'X'
:
logit
(
np
.
random
.
uniform
(
0
,
1
,
tuple
(
batch_size
+
[
num_classes
]))
.
astype
(
"float
32
"
)),
.
astype
(
"float
64
"
)),
'Label'
:
np
.
random
.
uniform
(
0
,
1
,
tuple
(
batch_size
+
[
num_classes
]))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
# Fw Pass is implemented as elementwise sigmoid followed by
...
...
@@ -189,9 +189,9 @@ class TestSigmoidCrossEntropyWithNorm2(OpTest):
self
.
inputs
=
{
'X'
:
logit
(
np
.
random
.
uniform
(
0
,
1
,
tuple
(
batch_size
+
[
num_classes
]))
.
astype
(
"float
32
"
)),
.
astype
(
"float
64
"
)),
'Label'
:
np
.
random
.
randint
(
-
1
,
2
,
tuple
(
batch_size
+
[
num_classes
]))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
self
.
attrs
=
{
'ignore_index'
:
ignore_index
,
'normalize'
:
True
}
sigmoid_X
=
expit
(
self
.
inputs
[
'X'
])
...
...
@@ -222,9 +222,9 @@ class TestSigmoidCrossEntropyWithLogitsOp6(OpTest):
self
.
inputs
=
{
'X'
:
logit
(
np
.
random
.
uniform
(
0
,
1
,
tuple
(
batch_size
+
[
num_classes
]))
.
astype
(
"float
32
"
)),
.
astype
(
"float
64
"
)),
'Label'
:
np
.
random
.
randint
(
0
,
2
,
tuple
(
batch_size
+
[
num_classes
]))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
# Fw Pass is implemented as elementwise sigmoid followed by
...
...
python/paddle/fluid/tests/unittests/test_sigmoid_focal_loss_op.py
浏览文件 @
f4379a91
...
...
@@ -65,7 +65,7 @@ class TestSigmoidFocalLossOp1(OpTest):
self
.
set_argument
()
dims
=
(
self
.
num_anchors
,
self
.
num_classes
)
X
=
np
.
random
.
standard_normal
(
dims
).
astype
(
"float
32
"
)
X
=
np
.
random
.
standard_normal
(
dims
).
astype
(
"float
64
"
)
L
=
np
.
random
.
randint
(
0
,
self
.
num_classes
+
1
,
(
dims
[
0
],
1
)).
astype
(
"int32"
)
F
=
np
.
zeros
(
1
)
...
...
@@ -85,7 +85,7 @@ class TestSigmoidFocalLossOp1(OpTest):
loss
=
sigmoid_focal_loss_forward
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Label'
],
self
.
inputs
[
'FgNum'
],
self
.
gamma
,
self
.
alpha
,
self
.
num_classes
)
self
.
outputs
=
{
'Out'
:
loss
.
astype
(
'float
32
'
)}
self
.
outputs
=
{
'Out'
:
loss
.
astype
(
'float
64
'
)}
def
test_check_output
(
self
):
self
.
check_output
()
...
...
python/paddle/fluid/tests/unittests/test_sign_op.py
浏览文件 @
f4379a91
...
...
@@ -25,7 +25,7 @@ class TestSignOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"sign"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
-
10
,
10
,
(
10
,
10
)).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
-
10
,
10
,
(
10
,
10
)).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
'Out'
:
np
.
sign
(
self
.
inputs
[
'X'
])}
...
...
python/paddle/fluid/tests/unittests/test_slice_op.py
浏览文件 @
f4379a91
...
...
@@ -37,7 +37,7 @@ class TestSliceOp(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
3
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -53,7 +53,7 @@ class TestSliceOp(OpTest):
class
TestCase1
(
TestSliceOp
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
-
3
,
0
,
2
]
self
.
ends
=
[
3
,
100
,
-
1
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -63,7 +63,7 @@ class TestCase1(TestSliceOp):
class
TestCase2
(
TestSliceOp
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
-
3
,
0
,
2
]
self
.
ends
=
[
3
,
100
,
-
1
]
self
.
axes
=
[
0
,
1
,
3
]
...
...
@@ -87,7 +87,7 @@ class TestSliceOp_decs_dim(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
2
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -104,7 +104,7 @@ class TestSliceOp_decs_dim(OpTest):
class
TestSliceOp_decs_dim_2
(
TestSliceOp_decs_dim
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
2
,
1
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -115,7 +115,7 @@ class TestSliceOp_decs_dim_2(TestSliceOp_decs_dim):
class
TestSliceOp_decs_dim_3
(
TestSliceOp_decs_dim
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
-
1
,
0
,
2
]
self
.
ends
=
[
1000000
,
1
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -126,7 +126,7 @@ class TestSliceOp_decs_dim_3(TestSliceOp_decs_dim):
class
TestSliceOp_decs_dim_4
(
TestSliceOp_decs_dim
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
7
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
7
]).
astype
(
"float
64
"
)
self
.
starts
=
[
0
,
1
,
2
,
3
]
self
.
ends
=
[
1
,
2
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
,
3
]
...
...
@@ -137,7 +137,7 @@ class TestSliceOp_decs_dim_4(TestSliceOp_decs_dim):
class
TestSliceOp_decs_dim_5
(
TestSliceOp_decs_dim
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
-
1
]
self
.
ends
=
[
1000000
]
self
.
axes
=
[
3
]
...
...
@@ -148,7 +148,7 @@ class TestSliceOp_decs_dim_5(TestSliceOp_decs_dim):
class
TestSliceOp_decs_dim_6
(
TestSliceOp_decs_dim
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
0
,
1
,
2
,
3
]
self
.
ends
=
[
1
,
2
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
,
3
]
...
...
@@ -179,7 +179,7 @@ class TestSliceOp_starts_ListTensor(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
3
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -219,7 +219,7 @@ class TestSliceOp_decs_dim_starts_ListTensor(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
2
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -239,7 +239,7 @@ class TestSliceOp_decs_dim_starts_ListTensor(OpTest):
class
TestSliceOp_decs_dim_5_starts_ListTensor
(
TestSliceOp_decs_dim_starts_ListTensor
):
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
-
1
]
self
.
ends
=
[
1000000
]
self
.
axes
=
[
3
]
...
...
@@ -271,7 +271,7 @@ class TestSliceOp_decs_dim_starts_OneTensor(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
2
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -309,7 +309,7 @@ class TestSliceOp_starts_OneTensor_ends_OneTensor(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
3
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -346,7 +346,7 @@ class TestSliceOp_decs_dim_starts_and_ends_OneTensor(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
2
,
1
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -388,7 +388,7 @@ class TestSliceOp_starts_OneTensor_ends_ListTensor(OpTest):
}
def
config
(
self
):
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
self
.
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
self
.
starts
=
[
1
,
0
,
2
]
self
.
ends
=
[
3
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -483,7 +483,7 @@ class TestFP16_2(OpTest):
# Test python API
class
TestSliceAPI
(
unittest
.
TestCase
):
def
test_1
(
self
):
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
32
"
)
input
=
np
.
random
.
random
([
3
,
4
,
5
,
6
]).
astype
(
"float
64
"
)
minus_1
=
fluid
.
layers
.
fill_constant
([
1
],
"int32"
,
-
1
)
minus_3
=
fluid
.
layers
.
fill_constant
([
1
],
"int32"
,
-
3
)
starts
=
fluid
.
layers
.
data
(
...
...
@@ -495,7 +495,7 @@ class TestSliceAPI(unittest.TestCase):
name
=
"x"
,
shape
=
[
3
,
4
,
5
,
6
],
append_batch_size
=
False
,
dtype
=
"float
32
"
)
dtype
=
"float
64
"
)
out_1
=
fluid
.
layers
.
slice
(
x
,
axes
=
[
0
,
1
,
2
],
starts
=
[
-
3
,
0
,
2
],
ends
=
[
3
,
100
,
-
1
])
...
...
python/paddle/fluid/tests/unittests/test_softmax_op.py
浏览文件 @
f4379a91
...
...
@@ -42,7 +42,7 @@ class TestSoftmaxOp(OpTest):
self
.
op_type
=
"softmax"
self
.
use_cudnn
=
False
self
.
use_mkldnn
=
False
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_kernel_type
()
self
.
shape
=
self
.
get_x_shape
()
self
.
axis
=
self
.
get_axis
()
...
...
python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py
浏览文件 @
f4379a91
...
...
@@ -126,7 +126,7 @@ class TestSoftmaxWithCrossEntropyOpFp16(TestSoftmaxWithCrossEntropyOp):
# NOTE: numpy float16 have very low accuracy, use float32 for numpy check.
logits
=
getattr
(
self
,
"logits"
,
np
.
random
.
uniform
(
0.1
,
1.0
,
self
.
shape
).
astype
(
np
.
float
32
))
np
.
random
.
uniform
(
0.1
,
1.0
,
self
.
shape
).
astype
(
np
.
float
64
))
softmax
=
np
.
apply_along_axis
(
stable_softmax
,
self
.
axis
,
logits
)
axis_dim
=
self
.
shape
[
self
.
axis
]
...
...
@@ -425,7 +425,7 @@ class TestSoftmaxWithCrossEntropyOpBoundary0(TestSoftmaxWithCrossEntropyOp):
self
.
shape
=
[
3
,
5
,
7
,
11
]
self
.
axis
=
-
1
self
.
ignore_index
=
-
1
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
logits
=
np
.
full
(
self
.
shape
,
-
500.0
).
astype
(
self
.
dtype
)
...
...
@@ -442,7 +442,7 @@ class TestSoftmaxWithCrossEntropyOpBoundary1(TestSoftmaxWithCrossEntropyOp):
self
.
shape
=
[
3
,
5
,
7
,
11
]
self
.
axis
=
-
1
self
.
ignore_index
=
-
1
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
logits
=
np
.
full
(
self
.
shape
,
1000.0
).
astype
(
self
.
dtype
)
self
.
logits
[:,
:,
0
,
:]
=
-
1000.0
...
...
python/paddle/fluid/tests/unittests/test_space_to_depth_op.py
浏览文件 @
f4379a91
...
...
@@ -58,9 +58,9 @@ class TestSpaceToDepthOp(OpTest):
self
.
one_d_len
=
32
*
48
*
3
*
3
self
.
blocksize
=
2
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
64
'
)
self
.
x_1d
=
np
.
reshape
(
self
.
x
,
self
.
one_d_len
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
32
'
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
64
'
)
self
.
out_1d
=
np
.
reshape
(
self
.
out
,
self
.
one_d_len
)
self
.
forward
=
1
...
...
@@ -82,9 +82,9 @@ class TestSpaceToDepthOpBasic(TestSpaceToDepthOp):
self
.
one_d_len
=
32
*
32
*
3
*
3
self
.
blocksize
=
2
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
64
'
)
self
.
x_1d
=
np
.
reshape
(
self
.
x
,
self
.
one_d_len
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
32
'
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
64
'
)
self
.
out_1d
=
np
.
reshape
(
self
.
out
,
self
.
one_d_len
)
self
.
forward
=
1
...
...
@@ -110,9 +110,9 @@ class TestSpaceToDepthOpWithStride3(TestSpaceToDepthOp):
self
.
one_d_len
=
32
*
81
*
2
*
2
self
.
blocksize
=
3
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
64
'
)
self
.
x_1d
=
np
.
reshape
(
self
.
x
,
self
.
one_d_len
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
32
'
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
64
'
)
self
.
out_1d
=
np
.
reshape
(
self
.
out
,
self
.
one_d_len
)
self
.
forward
=
1
...
...
@@ -124,9 +124,9 @@ class TestSpaceToDepthOpWithNotSquare(TestSpaceToDepthOp):
self
.
one_d_len
=
32
*
81
*
3
*
2
self
.
blocksize
=
3
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
32
'
)
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
'float
64
'
)
self
.
x_1d
=
np
.
reshape
(
self
.
x
,
self
.
one_d_len
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
32
'
)
self
.
out
=
np
.
zeros
(
self
.
infered_shape
).
astype
(
'float
64
'
)
self
.
out_1d
=
np
.
reshape
(
self
.
out
,
self
.
one_d_len
)
self
.
forward
=
1
...
...
python/paddle/fluid/tests/unittests/test_spectral_norm_op.py
浏览文件 @
f4379a91
...
...
@@ -49,9 +49,9 @@ class TestSpectralNormOpNoGrad(OpTest):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
op_type
=
'spectral_norm'
weight
=
np
.
random
.
random
(
self
.
weight_shape
).
astype
(
'float
32
'
)
u
=
np
.
random
.
normal
(
0.
,
1.
,
self
.
u_shape
).
astype
(
'float
32
'
)
v
=
np
.
random
.
normal
(
0.
,
1.
,
self
.
v_shape
).
astype
(
'float
32
'
)
weight
=
np
.
random
.
random
(
self
.
weight_shape
).
astype
(
'float
64
'
)
u
=
np
.
random
.
normal
(
0.
,
1.
,
self
.
u_shape
).
astype
(
'float
64
'
)
v
=
np
.
random
.
normal
(
0.
,
1.
,
self
.
v_shape
).
astype
(
'float
64
'
)
self
.
attrs
=
{
"dim"
:
self
.
dim
,
...
...
python/paddle/fluid/tests/unittests/test_split_op.py
浏览文件 @
f4379a91
...
...
@@ -34,7 +34,7 @@ class TestSplitOp(OpTest):
for
i
in
range
(
len
(
out
))]}
def
get_dtype
(
self
):
return
"float
32
"
return
"float
64
"
def
_set_op_type
(
self
):
self
.
op_type
=
"split"
...
...
@@ -71,7 +71,7 @@ class TestSplitOp_2(OpTest):
self
.
indices_or_sections
=
3
def
get_dtype
(
self
):
return
"float
32
"
return
"float
64
"
def
_set_op_type
(
self
):
self
.
op_type
=
"split"
...
...
@@ -107,7 +107,7 @@ class TestSplitOp_AxisTensor(OpTest):
self
.
indices_or_sections
=
3
def
get_dtype
(
self
):
return
"float
32
"
return
"float
64
"
def
_set_op_type
(
self
):
self
.
op_type
=
"split"
...
...
@@ -153,7 +153,7 @@ class TestSplitOp_SectionsTensor(OpTest):
self
.
indices_or_sections
=
[
2
,
3
]
def
get_dtype
(
self
):
return
"float
32
"
return
"float
64
"
def
_set_op_type
(
self
):
self
.
op_type
=
"split"
...
...
@@ -189,7 +189,7 @@ class TestSplitOp_unk_section(OpTest):
self
.
indices_or_sections
=
[
2
,
3
]
def
get_dtype
(
self
):
return
"float
32
"
return
"float
64
"
def
_set_op_type
(
self
):
self
.
op_type
=
"split"
...
...
python/paddle/fluid/tests/unittests/test_spp_op.py
浏览文件 @
f4379a91
...
...
@@ -25,7 +25,7 @@ class TestSppOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"spp"
self
.
init_test_case
()
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
32
"
)
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
64
"
)
nsize
,
csize
,
hsize
,
wsize
=
input
.
shape
out_level_flatten
=
[]
for
i
in
range
(
self
.
pyramid_height
):
...
...
@@ -50,13 +50,13 @@ class TestSppOp(OpTest):
else
:
output
=
np
.
concatenate
((
output
,
out_level_flatten
[
i
]),
1
)
# output = np.concatenate(out_level_flatten.tolist(), 0);
self
.
inputs
=
{
'X'
:
input
.
astype
(
'float
32
'
),
}
self
.
inputs
=
{
'X'
:
input
.
astype
(
'float
64
'
),
}
self
.
attrs
=
{
'pyramid_height'
:
self
.
pyramid_height
,
'pooling_type'
:
self
.
pool_type
}
self
.
outputs
=
{
'Out'
:
output
.
astype
(
'float
32
'
)}
self
.
outputs
=
{
'Out'
:
output
.
astype
(
'float
64
'
)}
def
test_check_output
(
self
):
self
.
check_output
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录