Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
b4ba35ca
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b4ba35ca
编写于
9月 13, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add groups test.
上级
1dd639eb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
24 deletion
+34
-24
python/paddle/v2/framework/tests/test_conv2d_op.py
python/paddle/v2/framework/tests/test_conv2d_op.py
+34
-24
未找到文件。
python/paddle/v2/framework/tests/test_conv2d_op.py
浏览文件 @
b4ba35ca
...
...
@@ -15,43 +15,53 @@ class TestConv2dOp(OpTest):
filter_width
=
3
stride
=
1
padding
=
0
groups
=
3
output_height
=
(
input_height
-
filter_height
+
2
*
padding
)
/
stride
+
1
output_width
=
(
input_width
-
filter_width
+
2
*
padding
)
/
stride
+
1
input
=
np
.
random
.
random
((
batch_size
,
input_channels
,
input_height
,
input_width
)).
astype
(
"float32"
)
filter
=
np
.
random
.
random
(
(
output_channels
,
input_channels
,
filter_height
,
(
output_channels
,
input_channels
/
groups
,
filter_height
,
filter_width
)).
astype
(
"float32"
)
output
=
np
.
ndarray
(
(
batch_size
,
output_channels
,
output_height
,
output_width
))
self
.
inputs
=
{
'Input'
:
input
,
'Filter'
:
filter
}
self
.
attrs
=
{
'strides'
:
[
1
,
1
],
'paddings'
:
[
0
,
0
]}
self
.
attrs
=
{
'strides'
:
[
1
,
1
],
'paddings'
:
[
0
,
0
]
,
'groups'
:
groups
}
output_group_channels
=
output_channels
/
groups
input_group_channels
=
input_channels
/
groups
for
batchid
in
xrange
(
batch_size
):
for
channelid
in
xrange
(
output_channels
):
for
rowid
in
xrange
(
output_height
):
for
colid
in
xrange
(
output_width
):
start_h
=
(
rowid
*
stride
)
-
padding
start_w
=
(
colid
*
stride
)
-
padding
output_value
=
0.0
for
inchannelid
in
xrange
(
input_channels
):
for
frowid
in
xrange
(
filter_height
):
for
fcolid
in
xrange
(
filter_width
):
input_value
=
0.0
inrowid
=
start_h
+
frowid
incolid
=
start_w
+
fcolid
if
((
inrowid
>=
0
and
inrowid
<
input_height
)
and
(
incolid
>=
0
and
incolid
<
input_width
)):
input_value
=
input
[
batchid
][
inchannelid
][
inrowid
][
incolid
]
filter_value
=
filter
[
channelid
][
inchannelid
][
frowid
][
fcolid
]
output_value
+=
input_value
*
filter_value
output
[
batchid
][
channelid
][
rowid
][
colid
]
=
output_value
for
group
in
xrange
(
groups
):
for
outchannelid
in
range
(
group
*
output_group_channels
,
(
group
+
1
)
*
output_group_channels
):
for
rowid
in
xrange
(
output_height
):
for
colid
in
xrange
(
output_width
):
start_h
=
(
rowid
*
stride
)
-
padding
start_w
=
(
colid
*
stride
)
-
padding
output_value
=
0.0
for
inchannelid
in
range
(
group
*
input_group_channels
,
(
group
+
1
)
*
input_group_channels
):
for
frowid
in
xrange
(
filter_height
):
for
fcolid
in
xrange
(
filter_width
):
input_value
=
0.0
inrowid
=
start_h
+
frowid
incolid
=
start_w
+
fcolid
if
((
inrowid
>=
0
and
inrowid
<
input_height
)
and
(
incolid
>=
0
and
incolid
<
input_width
)):
input_value
=
input
[
batchid
][
inchannelid
][
inrowid
][
incolid
]
filter_value
=
filter
[
outchannelid
][
inchannelid
%
input_group_channels
][
frowid
][
fcolid
]
output_value
+=
input_value
*
filter_value
output
[
batchid
][
outchannelid
][
rowid
][
colid
]
=
output_value
self
.
outputs
=
{
'Output'
:
output
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录