Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
91db457f
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
91db457f
编写于
10月 18, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comments
上级
24a796fb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
18 deletion
+18
-18
paddle/operators/conv3d_op.cc
paddle/operators/conv3d_op.cc
+2
-2
paddle/operators/conv3d_op.h
paddle/operators/conv3d_op.h
+14
-8
python/paddle/v2/framework/tests/test_conv3d_op.py
python/paddle/v2/framework/tests/test_conv3d_op.py
+2
-8
未找到文件。
paddle/operators/conv3d_op.cc
浏览文件 @
91db457f
...
@@ -87,11 +87,11 @@ Conv3DOpMaker::Conv3DOpMaker(framework::OpProto* proto,
...
@@ -87,11 +87,11 @@ Conv3DOpMaker::Conv3DOpMaker(framework::OpProto* proto,
"The format of output tensor is also NCDHW."
);
"The format of output tensor is also NCDHW."
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"strides of convolution operator."
)
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"strides of convolution operator."
)
.
SetDefault
({
1
,
1
,
1
});
.
SetDefault
({
1
,
1
,
1
});
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"paddings of convolution operator."
)
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"
The
paddings of convolution operator."
)
.
SetDefault
({
0
,
0
,
0
});
.
SetDefault
({
0
,
0
,
0
});
AddAttr
<
int
>
(
AddAttr
<
int
>
(
"groups"
,
"groups"
,
"group size of convolution operator. "
"
The
group size of convolution operator. "
"Refer to grouped convolution in Alex Krizhevsky's paper: "
"Refer to grouped convolution in Alex Krizhevsky's paper: "
"when group=2, the first half of the filters are only connected to the "
"when group=2, the first half of the filters are only connected to the "
"first half of the input channels, and the second half only connected "
"first half of the input channels, and the second half only connected "
...
...
paddle/operators/conv3d_op.h
浏览文件 @
91db457f
...
@@ -93,10 +93,13 @@ class GemmConv3DKernel : public framework::OpKernel<T> {
...
@@ -93,10 +93,13 @@ class GemmConv3DKernel : public framework::OpKernel<T> {
Tensor
col_matrix
=
col
;
Tensor
col_matrix
=
col
;
col_matrix
.
Resize
(
col_matrix_shape
);
col_matrix
.
Resize
(
col_matrix_shape
);
framework
::
DDim
input_shape
=
{
input
->
dims
()[
1
],
input
->
dims
()[
2
],
framework
::
DDim
input_shape
=
{
input
->
dims
()[
3
],
input
->
dims
()[
4
]};
input
->
dims
()[
1
],
input
->
dims
()[
2
],
input
->
dims
()[
3
],
framework
::
DDim
filter_matrix_shape
=
{
filter
.
dims
()[
0
],
input
->
dims
()[
4
]};
// channel, depth, height, width
filter
.
numel
()
/
filter
.
dims
()[
0
]};
framework
::
DDim
filter_matrix_shape
=
{
filter
.
dims
()[
0
],
filter
.
numel
()
/
filter
.
dims
()[
0
]};
// filter_out_channel,
// filter_in_channel*filter_depth*filter_height*filter_width
filter
.
Resize
(
filter_matrix_shape
);
filter
.
Resize
(
filter_matrix_shape
);
framework
::
DDim
output_matrix_shape
=
{
framework
::
DDim
output_matrix_shape
=
{
...
@@ -177,15 +180,18 @@ class GemmConvGrad3DKernel : public framework::OpKernel<T> {
...
@@ -177,15 +180,18 @@ class GemmConvGrad3DKernel : public framework::OpKernel<T> {
Tensor
col_matrix
=
col
;
Tensor
col_matrix
=
col
;
col_matrix
.
Resize
(
col_matrix_shape
);
col_matrix
.
Resize
(
col_matrix_shape
);
framework
::
DDim
input_shape
=
{
input
->
dims
()[
1
],
input
->
dims
()[
2
],
framework
::
DDim
input_shape
=
{
input
->
dims
()[
3
],
input
->
dims
()[
4
]};
input
->
dims
()[
1
],
input
->
dims
()[
2
],
input
->
dims
()[
3
],
input
->
dims
()[
4
]};
// channel, depth, height, width
framework
::
DDim
output_matrix_shape
=
{
output_grad
->
dims
()[
1
],
framework
::
DDim
output_matrix_shape
=
{
output_grad
->
dims
()[
1
],
output_grad
->
dims
()[
2
]
*
output_grad
->
dims
()[
2
]
*
output_grad
->
dims
()[
3
]
*
output_grad
->
dims
()[
3
]
*
output_grad
->
dims
()[
4
]};
output_grad
->
dims
()[
4
]};
framework
::
DDim
filter_matrix_shape
=
{
filter
.
dims
()[
0
],
framework
::
DDim
filter_matrix_shape
=
{
filter
.
numel
()
/
filter
.
dims
()[
0
]};
filter
.
dims
()[
0
],
filter
.
numel
()
/
filter
.
dims
()[
0
]};
// filter_out_channel,
// filter_in_channel*filter_depth*filter_height*filter_width
filter
.
Resize
(
filter_matrix_shape
);
filter
.
Resize
(
filter_matrix_shape
);
// convolution backward input operator: gemm + col2vol
// convolution backward input operator: gemm + col2vol
...
...
python/paddle/v2/framework/tests/test_conv3d_op.py
浏览文件 @
91db457f
...
@@ -34,7 +34,7 @@ def conv3d_forward_naive(input, filter, group, conv_param):
...
@@ -34,7 +34,7 @@ def conv3d_forward_naive(input, filter, group, conv_param):
for
k
in
range
(
sub_out_c
):
for
k
in
range
(
sub_out_c
):
out
[:,
g
*
sub_out_c
+
k
,
d
,
i
,
j
]
=
\
out
[:,
g
*
sub_out_c
+
k
,
d
,
i
,
j
]
=
\
np
.
sum
(
input_pad_masked
*
f_sub
[
k
,
:,
:,
:,
:],
np
.
sum
(
input_pad_masked
*
f_sub
[
k
,
:,
:,
:,
:],
axis
=
(
1
,
2
,
3
,
4
))
axis
=
(
1
,
2
,
3
,
4
))
return
out
return
out
...
@@ -65,7 +65,6 @@ class TestConv3dOp(OpTest):
...
@@ -65,7 +65,6 @@ class TestConv3dOp(OpTest):
self
.
check_grad
(
self
.
check_grad
(
set
([
'Input'
,
'Filter'
]),
'Output'
,
max_relative_error
=
0.05
)
set
([
'Input'
,
'Filter'
]),
'Output'
,
max_relative_error
=
0.05
)
def
test_check_grad_no_filter
(
self
):
self
.
check_grad
(
self
.
check_grad
(
[
'Input'
],
[
'Input'
],
'Output'
,
'Output'
,
...
@@ -80,8 +79,6 @@ class TestConv3dOp(OpTest):
...
@@ -80,8 +79,6 @@ class TestConv3dOp(OpTest):
no_grad_set
=
set
([
'Input'
]))
no_grad_set
=
set
([
'Input'
]))
def
init_test_case
(
self
):
def
init_test_case
(
self
):
# self.groups = 1
# self.op_type = "conv3d"
self
.
pad
=
[
0
,
0
,
0
]
self
.
pad
=
[
0
,
0
,
0
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
...
@@ -98,8 +95,6 @@ class TestConv3dOp(OpTest):
...
@@ -98,8 +95,6 @@ class TestConv3dOp(OpTest):
class
TestCase1
(
TestConv3dOp
):
class
TestCase1
(
TestConv3dOp
):
def
init_test_case
(
self
):
def
init_test_case
(
self
):
# self.groups = 1
# self.op_type = "conv3d"
self
.
pad
=
[
1
,
1
,
1
]
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
...
@@ -114,7 +109,6 @@ class TestCase1(TestConv3dOp):
...
@@ -114,7 +109,6 @@ class TestCase1(TestConv3dOp):
self
.
op_type
=
"conv3d"
self
.
op_type
=
"conv3d"
'''
class
TestWithGroup1
(
TestConv3dOp
):
class
TestWithGroup1
(
TestConv3dOp
):
def
init_group
(
self
):
def
init_group
(
self
):
self
.
groups
=
3
self
.
groups
=
3
...
@@ -129,7 +123,7 @@ class TestWithGroup2(TestCase1):
...
@@ -129,7 +123,7 @@ class TestWithGroup2(TestCase1):
def
init_op_type
(
self
):
def
init_op_type
(
self
):
self
.
op_type
=
"conv3d"
self
.
op_type
=
"conv3d"
'''
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录