Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bf9c5de7
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
bf9c5de7
编写于
12月 20, 2019
作者:
J
juncaipeng
提交者:
Tao Luo
12月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update test precision from fp32 to fp64 (#21848)
上级
2b1f08c7
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
51 addition
and
51 deletion
+51
-51
python/paddle/fluid/tests/unittests/test_squeeze2_op.py
python/paddle/fluid/tests/unittests/test_squeeze2_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_squeeze_op.py
python/paddle/fluid/tests/unittests/test_squeeze_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_stack_op.py
python/paddle/fluid/tests/unittests/test_stack_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_strided_slice_op.py
python/paddle/fluid/tests/unittests/test_strided_slice_op.py
+8
-8
python/paddle/fluid/tests/unittests/test_sum_op.py
python/paddle/fluid/tests/unittests/test_sum_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_teacher_student_sigmoid_loss_op.py
...d/tests/unittests/test_teacher_student_sigmoid_loss_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_temporal_shift_op.py
...on/paddle/fluid/tests/unittests/test_temporal_shift_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_transpose_op.py
python/paddle/fluid/tests/unittests/test_transpose_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_tree_conv_op.py
python/paddle/fluid/tests/unittests/test_tree_conv_op.py
+6
-6
python/paddle/fluid/tests/unittests/test_unfold_op.py
python/paddle/fluid/tests/unittests/test_unfold_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_unpool_op.py
python/paddle/fluid/tests/unittests/test_unpool_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py
python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py
+8
-8
python/paddle/fluid/tests/unittests/test_unsqueeze_op.py
python/paddle/fluid/tests/unittests/test_unsqueeze_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_unstack_op.py
python/paddle/fluid/tests/unittests/test_unstack_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_yolov3_loss_op.py
python/paddle/fluid/tests/unittests/test_yolov3_loss_op.py
+8
-8
未找到文件。
python/paddle/fluid/tests/unittests/test_squeeze2_op.py
浏览文件 @
bf9c5de7
...
...
@@ -25,11 +25,11 @@ class TestSqueezeOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"squeeze2"
self
.
init_test_case
()
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
),
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)
}
def
test_check_output
(
self
):
...
...
python/paddle/fluid/tests/unittests/test_squeeze_op.py
浏览文件 @
bf9c5de7
...
...
@@ -27,7 +27,7 @@ class TestSqueezeOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"squeeze"
self
.
init_test_case
()
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
),
}
...
...
python/paddle/fluid/tests/unittests/test_stack_op.py
浏览文件 @
bf9c5de7
...
...
@@ -22,7 +22,7 @@ class TestStackOpBase(OpTest):
self
.
num_inputs
=
4
self
.
input_dim
=
(
5
,
6
,
7
)
self
.
axis
=
0
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
def
initParameters
(
self
):
pass
...
...
python/paddle/fluid/tests/unittests/test_strided_slice_op.py
浏览文件 @
bf9c5de7
...
...
@@ -234,7 +234,7 @@ class TestStridedSliceOp_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
]
...
...
@@ -273,7 +273,7 @@ class TestStridedSliceOp_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
,
0
]
self
.
ends
=
[
3
,
3
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -310,7 +310,7 @@ class TestStridedSliceOp_starts_Tensor(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
]
...
...
@@ -345,7 +345,7 @@ class TestStridedSliceOp_ends_Tensor(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
]
...
...
@@ -386,7 +386,7 @@ class TestStridedSliceOp_listTensor_Tensor(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
]
...
...
@@ -421,7 +421,7 @@ class TestStridedSliceOp_strides_Tensor(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
,
-
1
,
2
]
self
.
ends
=
[
2
,
0
,
4
]
self
.
axes
=
[
0
,
1
,
2
]
...
...
@@ -440,7 +440,7 @@ class TestStridedSliceOp_strides_Tensor(OpTest):
# Test python API
class
TestStridedSliceAPI
(
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
(
...
...
@@ -454,7 +454,7 @@ class TestStridedSliceAPI(unittest.TestCase):
name
=
"x"
,
shape
=
[
3
,
4
,
5
,
6
],
append_batch_size
=
False
,
dtype
=
"float
32
"
)
dtype
=
"float
64
"
)
out_1
=
fluid
.
layers
.
strided_slice
(
x
,
axes
=
[
0
,
1
,
2
],
...
...
python/paddle/fluid/tests/unittests/test_sum_op.py
浏览文件 @
bf9c5de7
...
...
@@ -36,7 +36,7 @@ class TestSumOp(OpTest):
self
.
attrs
=
{
'use_mkldnn'
:
self
.
use_mkldnn
}
def
init_kernel_type
(
self
):
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
test_check_output
(
self
):
self
.
check_output
()
...
...
@@ -53,7 +53,7 @@ class TestSelectedRowsSumOp(unittest.TestCase):
self
.
height
=
10
self
.
row_numel
=
12
self
.
rows
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
]
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_kernel_type
()
def
check_with_place
(
self
,
place
,
inplace
):
...
...
@@ -144,7 +144,7 @@ class TestLoDTensorAndSelectedRowsOp(TestSelectedRowsSumOp):
self
.
height
=
10
self
.
row_numel
=
12
self
.
rows
=
[
0
,
1
,
2
,
2
,
4
,
5
,
6
]
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
check_with_place
(
self
,
place
,
inplace
):
scope
=
core
.
Scope
()
...
...
python/paddle/fluid/tests/unittests/test_teacher_student_sigmoid_loss_op.py
浏览文件 @
bf9c5de7
...
...
@@ -33,9 +33,9 @@ class TestTeacherStudentSigmoidLossOp(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
,
2
,
(
batch_size
,
num_classes
))
.
astype
(
"float
32
"
)
.
astype
(
"float
64
"
)
}
outs
=
[]
for
index
,
label
in
enumerate
(
self
.
inputs
[
"Label"
]):
...
...
python/paddle/fluid/tests/unittests/test_temporal_shift_op.py
浏览文件 @
bf9c5de7
...
...
@@ -39,7 +39,7 @@ class TestTemporalShift(OpTest):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
op_type
=
'temporal_shift'
x
=
np
.
random
.
random
(
self
.
x_shape
).
astype
(
'float
32
'
)
x
=
np
.
random
.
random
(
self
.
x_shape
).
astype
(
'float
64
'
)
self
.
attrs
=
{
"seg_num"
:
self
.
seg_num
,
...
...
python/paddle/fluid/tests/unittests/test_transpose_op.py
浏览文件 @
bf9c5de7
...
...
@@ -25,13 +25,13 @@ class TestTransposeOp(OpTest):
def
setUp
(
self
):
self
.
init_op_type
()
self
.
initTestCase
()
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
64
"
)}
self
.
attrs
=
{
'axis'
:
list
(
self
.
axis
),
'use_mkldnn'
:
self
.
use_mkldnn
,
}
self
.
outputs
=
{
'XShape'
:
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
32
"
),
'XShape'
:
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
64
"
),
'Out'
:
self
.
inputs
[
'X'
].
transpose
(
self
.
axis
)
}
...
...
@@ -83,7 +83,7 @@ class TestCase4(TestTransposeOp):
class
TestTransposeOpError
(
unittest
.
TestCase
):
def
test_errors
(
self
):
with
program_guard
(
Program
(),
Program
()):
x
=
fluid
.
layers
.
data
(
name
=
'x'
,
shape
=
[
10
,
5
,
3
],
dtype
=
'float
32
'
)
x
=
fluid
.
layers
.
data
(
name
=
'x'
,
shape
=
[
10
,
5
,
3
],
dtype
=
'float
64
'
)
def
test_x_Variable_check
():
# the Input(x)'s type must be Variable
...
...
python/paddle/fluid/tests/unittests/test_tree_conv_op.py
浏览文件 @
bf9c5de7
...
...
@@ -64,19 +64,19 @@ class TestTreeConvOp(OpTest):
adj
=
np
.
tile
(
adj
,
(
self
.
batch_size
,
1
,
1
))
self
.
op_type
=
'tree_conv'
vectors
=
np
.
random
.
random
(
(
self
.
batch_size
,
self
.
n
,
self
.
fea_size
)).
astype
(
'float
32
'
)
(
self
.
batch_size
,
self
.
n
,
self
.
fea_size
)).
astype
(
'float
64
'
)
self
.
inputs
=
{
'EdgeSet'
:
adj
,
'NodesVector'
:
vectors
,
'Filter'
:
np
.
random
.
random
((
self
.
fea_size
,
3
,
self
.
output_size
,
self
.
num_filters
)).
astype
(
'float
32
'
)
self
.
num_filters
)).
astype
(
'float
64
'
)
}
self
.
attrs
=
{
'max_depth'
:
self
.
max_depth
}
vectors
=
[]
for
i
in
range
(
self
.
batch_size
):
vector
=
self
.
get_output_naive
(
i
)
vectors
.
append
(
vector
)
self
.
outputs
=
{
'Out'
:
np
.
array
(
vectors
).
astype
(
'float
32
'
),
}
self
.
outputs
=
{
'Out'
:
np
.
array
(
vectors
).
astype
(
'float
64
'
),
}
def
test_check_output
(
self
):
self
.
check_output
()
...
...
@@ -91,7 +91,7 @@ class TestTreeConvOp(OpTest):
for
e
in
st
:
og
[
e
[
0
]].
append
(
e
[
1
])
patches
=
collect_node_patch
(
og
,
self
.
max_depth
)
W
=
np
.
array
(
self
.
inputs
[
'Filter'
]).
astype
(
'float
32
'
)
W
=
np
.
array
(
self
.
inputs
[
'Filter'
]).
astype
(
'float
64
'
)
W
=
np
.
transpose
(
W
,
axes
=
[
1
,
0
,
2
,
3
])
vec
=
[]
for
i
,
patch
in
enumerate
(
patches
,
1
):
...
...
@@ -103,7 +103,7 @@ class TestTreeConvOp(OpTest):
eta_r
=
(
1.0
-
eta_t
)
*
(
1.0
-
eta_l
)
x
=
self
.
inputs
[
'NodesVector'
][
batch_id
][
v
[
0
]
-
1
]
eta
=
np
.
array
([
eta_l
,
eta_r
,
eta_t
]).
reshape
(
(
3
,
1
)).
astype
(
'float
32
'
)
(
3
,
1
)).
astype
(
'float
64
'
)
Wconvi
=
np
.
tensordot
(
eta
,
W
,
axes
=
([
0
],
[
0
]))
x
=
np
.
array
(
x
).
reshape
((
1
,
1
,
self
.
fea_size
))
res
=
np
.
tensordot
(
x
,
Wconvi
,
axes
=
2
)
...
...
@@ -114,7 +114,7 @@ class TestTreeConvOp(OpTest):
[
vec
,
np
.
zeros
(
(
self
.
n
-
vec
.
shape
[
0
],
W
.
shape
[
2
],
W
.
shape
[
3
]),
dtype
=
'float
32
'
)
dtype
=
'float
64
'
)
],
axis
=
0
)
return
vec
python/paddle/fluid/tests/unittests/test_unfold_op.py
浏览文件 @
bf9c5de7
...
...
@@ -38,7 +38,7 @@ class TestUnfoldOp(OpTest):
self
.
batch_size
,
self
.
input_channels
,
self
.
input_height
,
self
.
input_width
]
self
.
x
=
np
.
random
.
rand
(
*
input_shape
).
astype
(
np
.
float
32
)
self
.
x
=
np
.
random
.
rand
(
*
input_shape
).
astype
(
np
.
float
64
)
def
calc_unfold
(
self
):
output_shape
=
[
0
]
*
3
...
...
@@ -52,7 +52,7 @@ class TestUnfoldOp(OpTest):
out_width
=
int
((
self
.
input_width
+
self
.
paddings
[
1
]
+
self
.
paddings
[
3
]
-
dkernel_w
)
/
self
.
strides
[
1
])
+
1
output_shape
[
2
]
=
out_height
*
out_width
output
=
np
.
zeros
(
output_shape
).
astype
(
np
.
float
32
)
output
=
np
.
zeros
(
output_shape
).
astype
(
np
.
float
64
)
############ calculate output ##############
for
i
in
range
(
output_shape
[
0
]):
for
j
in
range
(
output_shape
[
1
]):
...
...
python/paddle/fluid/tests/unittests/test_unpool_op.py
浏览文件 @
bf9c5de7
...
...
@@ -41,7 +41,7 @@ class TestUnpoolOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"unpool"
self
.
init_test_case
()
pre_input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
32
"
)
pre_input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float
64
"
)
nsize
,
csize
,
hsize
,
wsize
=
pre_input
.
shape
hsize_out
=
(
hsize
-
self
.
ksize
[
0
]
+
2
*
self
.
paddings
[
0
])
//
\
self
.
strides
[
0
]
+
1
...
...
@@ -67,9 +67,9 @@ class TestUnpoolOp(OpTest):
(
r_start
+
arg
//
self
.
ksize
[
1
])
*
wsize
+
\
c_start
+
arg
%
self
.
ksize
[
1
]
output
=
self
.
unpool2d_forward_naive
(
input
,
indices
,
self
.
ksize
,
\
self
.
strides
,
self
.
paddings
).
astype
(
"float
32
"
)
self
.
strides
,
self
.
paddings
).
astype
(
"float
64
"
)
self
.
inputs
=
{
'X'
:
input
.
astype
(
'float
32
'
),
'X'
:
input
.
astype
(
'float
64
'
),
'Indices'
:
indices
.
astype
(
'int32'
)
}
self
.
attrs
=
{
...
...
@@ -78,7 +78,7 @@ class TestUnpoolOp(OpTest):
'ksize'
:
self
.
ksize
,
'unpooling_type'
:
self
.
unpooling_type
,
}
self
.
outputs
=
{
'Out'
:
output
.
astype
(
'float
32
'
)}
self
.
outputs
=
{
'Out'
:
output
.
astype
(
'float
64
'
)}
def
test_check_output
(
self
):
self
.
check_output
()
...
...
python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py
浏览文件 @
bf9c5de7
...
...
@@ -25,11 +25,11 @@ class TestUnsqueezeOp(OpTest):
def
setUp
(
self
):
self
.
init_test_case
()
self
.
op_type
=
"unsqueeze2"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
),
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)
}
def
test_check_output
(
self
):
...
...
@@ -91,13 +91,13 @@ class TestUnsqueezeOp_AxesTensorList(OpTest):
(
1
)).
astype
(
'int32'
)
*
ele
))
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
),
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
),
"AxesTensorList"
:
axes_tensor_list
}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
),
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)
}
def
test_check_output
(
self
):
...
...
@@ -150,13 +150,13 @@ class TestUnsqueezeOp_AxesTensor(OpTest):
self
.
op_type
=
"unsqueeze2"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
),
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
),
"AxesTensor"
:
np
.
array
(
self
.
axes
).
astype
(
"int32"
)
}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
),
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)
"XShape"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)
}
def
test_check_output
(
self
):
...
...
@@ -205,8 +205,8 @@ class TestUnsqueezeOp4_AxesTensor(TestUnsqueezeOp_AxesTensor):
# test api
class
TestUnsqueezeAPI
(
unittest
.
TestCase
):
def
test_api
(
self
):
input
=
np
.
random
.
random
([
3
,
2
,
5
]).
astype
(
"float
32
"
)
x
=
fluid
.
data
(
name
=
'x'
,
shape
=
[
3
,
2
,
5
],
dtype
=
"float
32
"
)
input
=
np
.
random
.
random
([
3
,
2
,
5
]).
astype
(
"float
64
"
)
x
=
fluid
.
data
(
name
=
'x'
,
shape
=
[
3
,
2
,
5
],
dtype
=
"float
64
"
)
positive_3_int32
=
fluid
.
layers
.
fill_constant
([
1
],
"int32"
,
3
)
positive_1_int64
=
fluid
.
layers
.
fill_constant
([
1
],
"int64"
,
1
)
axes_tensor_int32
=
fluid
.
data
(
...
...
python/paddle/fluid/tests/unittests/test_unsqueeze_op.py
浏览文件 @
bf9c5de7
...
...
@@ -25,7 +25,7 @@ class TestUnsqueezeOp(OpTest):
def
setUp
(
self
):
self
.
init_test_case
()
self
.
op_type
=
"unsqueeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
)}
...
...
python/paddle/fluid/tests/unittests/test_unstack_op.py
浏览文件 @
bf9c5de7
...
...
@@ -21,7 +21,7 @@ class TestUnStackOpBase(OpTest):
def
initDefaultParameters
(
self
):
self
.
input_dim
=
(
5
,
6
,
7
)
self
.
axis
=
0
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
def
initParameters
(
self
):
pass
...
...
python/paddle/fluid/tests/unittests/test_yolov3_loss_op.py
浏览文件 @
bf9c5de7
...
...
@@ -79,7 +79,7 @@ def YOLOv3Loss(x, gtbox, gtlabel, gtscore, attrs):
use_label_smooth
=
attrs
[
'use_label_smooth'
]
input_size
=
downsample_ratio
*
h
x
=
x
.
reshape
((
n
,
mask_num
,
5
+
class_num
,
h
,
w
)).
transpose
((
0
,
1
,
3
,
4
,
2
))
loss
=
np
.
zeros
((
n
)).
astype
(
'float
32
'
)
loss
=
np
.
zeros
((
n
)).
astype
(
'float
64
'
)
smooth_weight
=
min
(
1.0
/
class_num
,
1.0
/
40
)
label_pos
=
1.0
-
smooth_weight
if
use_label_smooth
else
1.0
...
...
@@ -103,7 +103,7 @@ def YOLOv3Loss(x, gtbox, gtlabel, gtscore, attrs):
pred_box
=
pred_box
.
reshape
((
n
,
-
1
,
4
))
pred_obj
=
x
[:,
:,
:,
:,
4
].
reshape
((
n
,
-
1
))
objness
=
np
.
zeros
(
pred_box
.
shape
[:
2
]).
astype
(
'float
32
'
)
objness
=
np
.
zeros
(
pred_box
.
shape
[:
2
]).
astype
(
'float
64
'
)
ious
=
batch_xywh_box_iou
(
pred_box
,
gtbox
)
ious_max
=
np
.
max
(
ious
,
axis
=-
1
)
objness
=
np
.
where
(
ious_max
>
ignore_thresh
,
-
np
.
ones_like
(
objness
),
...
...
@@ -158,7 +158,7 @@ def YOLOv3Loss(x, gtbox, gtlabel, gtscore, attrs):
elif
objness
[
i
,
j
]
==
0
:
loss
[
i
]
+=
sce
(
pred_obj
[
i
,
j
],
0.0
)
return
(
loss
,
objness
.
reshape
((
n
,
mask_num
,
h
,
w
)).
astype
(
'float
32
'
),
\
return
(
loss
,
objness
.
reshape
((
n
,
mask_num
,
h
,
w
)).
astype
(
'float
64
'
),
\
gt_matches
.
astype
(
'int32'
))
...
...
@@ -166,8 +166,8 @@ class TestYolov3LossOp(OpTest):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
op_type
=
'yolov3_loss'
x
=
logit
(
np
.
random
.
uniform
(
0
,
1
,
self
.
x_shape
).
astype
(
'float
32
'
))
gtbox
=
np
.
random
.
random
(
size
=
self
.
gtbox_shape
).
astype
(
'float
32
'
)
x
=
logit
(
np
.
random
.
uniform
(
0
,
1
,
self
.
x_shape
).
astype
(
'float
64
'
))
gtbox
=
np
.
random
.
random
(
size
=
self
.
gtbox_shape
).
astype
(
'float
64
'
)
gtlabel
=
np
.
random
.
randint
(
0
,
self
.
class_num
,
self
.
gtbox_shape
[:
2
])
gtmask
=
np
.
random
.
randint
(
0
,
2
,
self
.
gtbox_shape
[:
2
])
gtbox
=
gtbox
*
gtmask
[:,
:,
np
.
newaxis
]
...
...
@@ -184,13 +184,13 @@ class TestYolov3LossOp(OpTest):
self
.
inputs
=
{
'X'
:
x
,
'GTBox'
:
gtbox
.
astype
(
'float
32
'
),
'GTBox'
:
gtbox
.
astype
(
'float
64
'
),
'GTLabel'
:
gtlabel
.
astype
(
'int32'
),
}
gtscore
=
np
.
ones
(
self
.
gtbox_shape
[:
2
]).
astype
(
'float
32
'
)
gtscore
=
np
.
ones
(
self
.
gtbox_shape
[:
2
]).
astype
(
'float
64
'
)
if
self
.
gtscore
:
gtscore
=
np
.
random
.
random
(
self
.
gtbox_shape
[:
2
]).
astype
(
'float
32
'
)
gtscore
=
np
.
random
.
random
(
self
.
gtbox_shape
[:
2
]).
astype
(
'float
64
'
)
self
.
inputs
[
'GTScore'
]
=
gtscore
loss
,
objness
,
gt_matches
=
YOLOv3Loss
(
x
,
gtbox
,
gtlabel
,
gtscore
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录