Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
d44dbc4a
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看板
提交
d44dbc4a
编写于
5月 28, 2018
作者:
F
fengjiayi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix errors
上级
3e7ce583
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
5 deletion
+19
-5
paddle/fluid/operators/random_crop_op.h
paddle/fluid/operators/random_crop_op.h
+1
-1
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+2
-0
python/paddle/fluid/tests/unittests/test_random_crop_op.py
python/paddle/fluid/tests/unittests/test_random_crop_op.py
+16
-4
未找到文件。
paddle/fluid/operators/random_crop_op.h
浏览文件 @
d44dbc4a
...
@@ -129,7 +129,7 @@ struct RandomCropFunctor {
...
@@ -129,7 +129,7 @@ struct RandomCropFunctor {
for
(
int
i
=
num_batchsize_dims_
;
i
<
rank_
;
++
i
)
{
for
(
int
i
=
num_batchsize_dims_
;
i
<
rank_
;
++
i
)
{
typename
Random
<
DeviceContext
>::
template
UniformIntDist
<
size_t
>
dist
(
typename
Random
<
DeviceContext
>::
template
UniformIntDist
<
size_t
>
dist
(
0
,
x_dims_
[
i
]
-
out_dims_
[
i
]);
0
,
x_dims_
[
i
]
-
out_dims_
[
i
]);
offsets
[
i
]
=
dist
(
engine
);
offsets
[
i
-
num_batchsize_dims_
]
=
dist
(
engine
);
}
}
const
T
*
x
=
x_
+
ins_idx
*
prod_x_ins_dims_
;
const
T
*
x
=
x_
+
ins_idx
*
prod_x_ins_dims_
;
...
...
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
d44dbc4a
...
@@ -336,6 +336,8 @@ class OpTest(unittest.TestCase):
...
@@ -336,6 +336,8 @@ class OpTest(unittest.TestCase):
actual_t
=
np
.
array
(
actual
)
actual_t
=
np
.
array
(
actual
)
expect
=
self
.
outputs
[
out_name
]
expect
=
self
.
outputs
[
out_name
]
expect_t
=
expect
[
0
]
if
isinstance
(
expect
,
tuple
)
else
expect
expect_t
=
expect
[
0
]
if
isinstance
(
expect
,
tuple
)
else
expect
import
pdb
pdb
.
set_trace
()
self
.
assertTrue
(
self
.
assertTrue
(
np
.
allclose
(
np
.
allclose
(
actual_t
,
expect_t
,
atol
=
atol
),
actual_t
,
expect_t
,
atol
=
atol
),
...
...
python/paddle/fluid/tests/unittests/test_random_crop_op.py
浏览文件 @
d44dbc4a
...
@@ -20,14 +20,26 @@ from op_test import OpTest
...
@@ -20,14 +20,26 @@ from op_test import OpTest
class
TestRandomCropOp
(
OpTest
):
class
TestRandomCropOp
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
to_crop
=
np
.
random
.
random
((
1
,
10
,
15
)).
astype
(
"float32"
)
to_crop
=
np
.
array
([[[
1
,
2
,
3
,
4
],
[
5
,
6
,
7
,
8
],
[
9
,
10
,
11
,
12
]]]
*
5
).
astype
(
"float32"
)
self
.
possible_res
=
[
np
.
array
([[
1
,
2
,
3
],
[
5
,
6
,
7
]]),
np
.
array
([[
2
,
3
,
4
],
[
6
,
7
,
8
]]),
np
.
array
([[
5
,
6
,
7
],
[
9
,
10
,
11
]]),
np
.
array
([[
6
,
7
,
8
],
[
10
,
11
,
12
]])
]
self
.
op_type
=
"random_crop"
self
.
op_type
=
"random_crop"
self
.
inputs
=
{
'X'
:
to_crop
,
'Seed'
:
np
.
array
([
10
])}
self
.
inputs
=
{
'X'
:
to_crop
,
'Seed'
:
np
.
array
([
10
])}
self
.
outputs
=
{
'Out'
:
np
.
array
([
1
,
2
,
3
]),
'SeedOut'
:
np
.
array
([
2
])}
self
.
outputs
=
{
'Out'
:
np
.
array
([
]),
'SeedOut'
:
np
.
array
([
])}
self
.
attrs
=
{
'shape'
:
[
5
,
5
]}
self
.
attrs
=
{
'shape'
:
[
2
,
3
]}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
()
self
.
check_output_customized
(
self
.
verify_output
)
def
verify_output
(
self
,
outs
):
out
=
np
.
array
(
outs
[
1
])
for
ins
in
out
[:]:
is_equal
=
[(
ins
==
res
).
all
()
for
res
in
self
.
possible_res
]
self
.
assertIn
(
True
,
is_equal
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录