Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
6ef2da2e
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看板
提交
6ef2da2e
编写于
10月 12, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finetune conv2d navie func
上级
92c39441
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
11 deletion
+10
-11
python/paddle/v2/framework/tests/test_conv2d_op.py
python/paddle/v2/framework/tests/test_conv2d_op.py
+10
-11
未找到文件。
python/paddle/v2/framework/tests/test_conv2d_op.py
浏览文件 @
6ef2da2e
...
@@ -11,19 +11,19 @@ def conv2d_forward_naive(input, filter, group, conv_param):
...
@@ -11,19 +11,19 @@ def conv2d_forward_naive(input, filter, group, conv_param):
sub_out_c
=
out_c
/
group
sub_out_c
=
out_c
/
group
stride
,
pad
=
conv_param
[
'stride'
],
conv_param
[
'pad'
]
stride
,
pad
=
conv_param
[
'stride'
],
conv_param
[
'pad'
]
out_h
=
1
+
(
in_h
+
2
*
pad
-
f_h
)
/
stride
out_h
=
1
+
(
in_h
+
2
*
pad
[
0
]
-
f_h
)
/
stride
[
0
]
out_w
=
1
+
(
in_w
+
2
*
pad
-
f_w
)
/
stride
out_w
=
1
+
(
in_w
+
2
*
pad
[
1
]
-
f_w
)
/
stride
[
1
]
out
=
np
.
zeros
((
in_n
,
out_c
,
out_h
,
out_w
))
out
=
np
.
zeros
((
in_n
,
out_c
,
out_h
,
out_w
))
input_pad
=
np
.
pad
(
input
,
((
0
,
),
(
0
,
),
(
pad
,
),
(
pad
,
)),
input_pad
=
np
.
pad
(
input
,
((
0
,
),
(
0
,
),
(
pad
[
0
],
),
(
pad
[
1
]
,
)),
mode
=
'constant'
,
mode
=
'constant'
,
constant_values
=
0
)
constant_values
=
0
)
for
i
in
range
(
out_h
):
for
i
in
range
(
out_h
):
for
j
in
range
(
out_w
):
for
j
in
range
(
out_w
):
for
g
in
range
(
group
):
for
g
in
range
(
group
):
input_pad_masked
=
input_pad
[:,
g
*
f_c
:(
input_pad_masked
=
input_pad
[:,
g
*
f_c
:(
g
+
1
)
*
f_c
,
i
*
stride
:
i
*
stride
+
f_h
,
j
*
stride
:
j
*
g
+
1
)
*
f_c
,
i
*
stride
[
0
]:
i
*
stride
[
0
]
+
f_h
,
j
*
stride
[
stride
+
f_w
]
1
]:
j
*
stride
[
1
]
+
f_w
]
f_sub
=
filter
[
g
*
sub_out_c
:(
g
+
1
)
*
sub_out_c
,
:,
:,
:]
f_sub
=
filter
[
g
*
sub_out_c
:(
g
+
1
)
*
sub_out_c
,
:,
:,
:]
for
k
in
range
(
sub_out_c
):
for
k
in
range
(
sub_out_c
):
out
[:,
g
*
sub_out_c
+
k
,
i
,
j
]
=
np
.
sum
(
input_pad_masked
*
out
[:,
g
*
sub_out_c
+
k
,
i
,
j
]
=
np
.
sum
(
input_pad_masked
*
...
@@ -37,11 +37,14 @@ class TestConv2dOp(OpTest):
...
@@ -37,11 +37,14 @@ class TestConv2dOp(OpTest):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
init_groups
()
self
.
init_groups
()
self
.
op_type
=
"conv2d"
self
.
op_type
=
"conv2d"
pad
=
[
0
,
0
]
stride
=
[
1
,
1
]
input_size
=
[
2
,
3
,
5
,
5
]
# NCHW
input_size
=
[
2
,
3
,
5
,
5
]
# NCHW
assert
np
.
mod
(
input_size
[
1
],
self
.
groups
)
==
0
assert
np
.
mod
(
input_size
[
1
],
self
.
groups
)
==
0
f_c
=
input_size
[
1
]
/
self
.
groups
f_c
=
input_size
[
1
]
/
self
.
groups
filter_size
=
[
6
,
f_c
,
3
,
3
]
filter_size
=
[
6
,
f_c
,
3
,
3
]
conv2d_param
=
{
'stride'
:
1
,
'pad'
:
0
}
conv2d_param
=
{
'stride'
:
stride
,
'pad'
:
pad
}
input
=
np
.
random
.
random
(
input_size
).
astype
(
"float32"
)
input
=
np
.
random
.
random
(
input_size
).
astype
(
"float32"
)
filter
=
np
.
random
.
random
(
filter_size
).
astype
(
"float32"
)
filter
=
np
.
random
.
random
(
filter_size
).
astype
(
"float32"
)
...
@@ -49,11 +52,7 @@ class TestConv2dOp(OpTest):
...
@@ -49,11 +52,7 @@ class TestConv2dOp(OpTest):
output
=
conv2d_forward_naive
(
input
,
filter
,
self
.
groups
,
conv2d_param
)
output
=
conv2d_forward_naive
(
input
,
filter
,
self
.
groups
,
conv2d_param
)
self
.
inputs
=
{
'Input'
:
input
,
'Filter'
:
filter
}
self
.
inputs
=
{
'Input'
:
input
,
'Filter'
:
filter
}
self
.
attrs
=
{
self
.
attrs
=
{
'strides'
:
stride
,
'paddings'
:
pad
,
'groups'
:
self
.
groups
}
'strides'
:
[
1
,
1
],
'paddings'
:
[
0
,
0
],
'groups'
:
self
.
groups
}
self
.
outputs
=
{
'Output'
:
output
}
self
.
outputs
=
{
'Output'
:
output
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录