Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5f655d2c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
5f655d2c
编写于
1月 21, 2020
作者:
W
whs
提交者:
Tao Luo
1月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine unitest im2seq op. (#22372)
上级
de9edf58
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
36 deletion
+11
-36
python/paddle/fluid/tests/unittests/test_im2sequence_op.py
python/paddle/fluid/tests/unittests/test_im2sequence_op.py
+11
-36
未找到文件。
python/paddle/fluid/tests/unittests/test_im2sequence_op.py
浏览文件 @
5f655d2c
...
...
@@ -15,7 +15,7 @@
from
__future__
import
print_function
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
def
get_output_shape
(
attrs
,
in_shape
,
img_real_size
):
...
...
@@ -142,7 +142,6 @@ class TestBlockExpandOp(OpTest):
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
self
.
batch_size
,
self
.
img_channels
,
self
.
img_height
,
self
.
img_width
]).
astype
(
"float32"
)
real_size
=
np
.
array
([]).
astype
(
"float32"
)
out
=
Im2Sequence
(
x
,
real_size
,
self
.
attrs
)
self
.
inputs
=
{
'X'
:
x
}
...
...
@@ -194,6 +193,9 @@ class TestBlockExpandOpCase4(TestBlockExpandOp):
}
@
skip_check_grad_ci
(
reason
=
"Since 'real_size' is used just in forward computation, we don't test the gradient here."
)
class
TestBlockExpandOpCase5
(
OpTest
):
def
config
(
self
):
self
.
batch_size
=
1
...
...
@@ -206,6 +208,7 @@ class TestBlockExpandOpCase5(OpTest):
'paddings'
:
[
2
,
1
,
2
,
1
],
'out_stride'
:
[
2
,
2
],
}
self
.
real_size
=
np
.
array
([[
8
,
10
],
[
5
,
8
]]).
astype
(
"float32"
)
def
setUp
(
self
):
self
.
config
()
...
...
@@ -213,16 +216,15 @@ class TestBlockExpandOpCase5(OpTest):
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
self
.
batch_size
,
self
.
img_channels
,
self
.
img_height
,
self
.
img_width
]).
astype
(
"float32"
)
real_size
=
np
.
array
([[
8
,
10
],
[
5
,
8
]]).
astype
(
"float32"
)
out
=
np
.
array
(
Im2Sequence
(
x
,
real_size
,
self
.
attrs
))
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
real_size
}
#l ??
out
=
np
.
array
(
Im2Sequence
(
x
,
self
.
real_size
,
self
.
attrs
))
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
self
.
real_size
}
self
.
outputs
=
{
'Out'
:
out
}
def
test_check_output
(
self
):
self
.
check_output
()
class
TestBlockExpandOpCase6
(
OpTest
):
class
TestBlockExpandOpCase6
(
TestBlockExpandOpCase5
):
def
config
(
self
):
self
.
batch_size
=
3
self
.
img_channels
=
1
...
...
@@ -234,23 +236,10 @@ class TestBlockExpandOpCase6(OpTest):
'paddings'
:
[
0
,
0
,
0
,
0
],
'out_stride'
:
[
1
,
1
],
}
def
setUp
(
self
):
self
.
config
()
self
.
op_type
=
"im2sequence"
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
self
.
batch_size
,
self
.
img_channels
,
self
.
img_height
,
self
.
img_width
]).
astype
(
"float32"
)
real_size
=
np
.
array
([[
8
,
10
],
[
5
,
8
],
[
5
,
8
]]).
astype
(
"float32"
)
out
=
np
.
array
(
Im2Sequence
(
x
,
real_size
,
self
.
attrs
))
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
real_size
}
#l ??
self
.
outputs
=
{
'Out'
:
out
}
def
test_check_output
(
self
):
self
.
check_output
()
self
.
real_size
=
np
.
array
([[
8
,
10
],
[
5
,
8
],
[
5
,
8
]]).
astype
(
"float32"
)
class
TestBlockExpandOpCase7
(
OpTest
):
class
TestBlockExpandOpCase7
(
TestBlockExpandOpCase6
):
def
config
(
self
):
self
.
batch_size
=
2
self
.
img_channels
=
2
...
...
@@ -262,22 +251,8 @@ class TestBlockExpandOpCase7(OpTest):
'paddings'
:
[
1
,
0
,
1
,
0
],
'out_stride'
:
[
2
,
2
],
}
def
setUp
(
self
):
self
.
config
()
self
.
op_type
=
"im2sequence"
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
self
.
batch_size
,
self
.
img_channels
,
self
.
img_height
,
self
.
img_width
]).
astype
(
"float32"
)
real_size
=
np
.
array
([[
6
,
6
],
[
4
,
4
]]).
astype
(
"float32"
)
out
=
np
.
array
(
Im2Sequence
(
x
,
real_size
,
self
.
attrs
))
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
real_size
}
self
.
outputs
=
{
'Out'
:
out
}
def
test_check_output
(
self
):
self
.
check_output
()
self
.
real_size
=
np
.
array
([[
6
,
6
],
[
4
,
4
]]).
astype
(
"float32"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
#set shiftwidth=4 set expandtab set tabstop=4
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录