Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
78260ff3
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2293
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
78260ff3
编写于
6月 16, 2021
作者:
W
wangguanzhong
提交者:
GitHub
6月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix output_padding in conv (#33585)
* fix output padding conv * add repr unittest for conv
上级
e6c5282e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
6 deletion
+19
-6
python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
.../paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
+13
-0
python/paddle/nn/layer/conv.py
python/paddle/nn/layer/conv.py
+6
-6
未找到文件。
python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
浏览文件 @
78260ff3
...
@@ -18,6 +18,7 @@ import unittest
...
@@ -18,6 +18,7 @@ import unittest
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
import
paddle.nn
as
nn
paddle
.
enable_static
()
paddle
.
enable_static
()
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
...
@@ -898,5 +899,17 @@ class TestConv2DTransposeOpException(unittest.TestCase):
...
@@ -898,5 +899,17 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
attr_padding_with_data_format
)
self
.
assertRaises
(
ValueError
,
attr_padding_with_data_format
)
class
TestConv2DTransposeRepr
(
unittest
.
TestCase
):
def
test_case
(
self
):
paddle
.
disable_static
()
x_var
=
paddle
.
uniform
((
2
,
4
,
8
,
8
),
dtype
=
'float32'
,
min
=-
1.
,
max
=
1.
)
conv
=
nn
.
Conv2DTranspose
(
4
,
6
,
(
3
,
3
),
output_padding
=
1
,
stride
=
2
)
print
(
conv
)
y_var
=
conv
(
x_var
)
y_np
=
y_var
.
numpy
()
self
.
assertIsNotNone
(
y_np
)
paddle
.
enable_static
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
python/paddle/nn/layer/conv.py
浏览文件 @
78260ff3
...
@@ -98,7 +98,7 @@ class _ConvNd(layers.Layer):
...
@@ -98,7 +98,7 @@ class _ConvNd(layers.Layer):
'kernel_size'
)
'kernel_size'
)
self
.
_padding
=
padding
self
.
_padding
=
padding
self
.
_padding_mode
=
padding_mode
self
.
_padding_mode
=
padding_mode
self
.
_
output_padding
=
output_padding
self
.
output_padding
=
output_padding
if
dims
!=
1
:
if
dims
!=
1
:
self
.
_updated_padding
,
self
.
_padding_algorithm
=
_update_padding_nd
(
self
.
_updated_padding
,
self
.
_padding_algorithm
=
_update_padding_nd
(
padding
,
channel_last
,
dims
)
padding
,
channel_last
,
dims
)
...
@@ -163,8 +163,8 @@ class _ConvNd(layers.Layer):
...
@@ -163,8 +163,8 @@ class _ConvNd(layers.Layer):
main_str
+=
', padding={_padding}'
main_str
+=
', padding={_padding}'
if
self
.
_padding_mode
is
not
'zeros'
:
if
self
.
_padding_mode
is
not
'zeros'
:
main_str
+=
', padding_mode={_padding_mode}'
main_str
+=
', padding_mode={_padding_mode}'
if
self
.
_
output_padding
!=
0
:
if
self
.
output_padding
!=
0
:
main_str
+=
', output_padding={
_
output_padding}'
main_str
+=
', output_padding={output_padding}'
if
self
.
_dilation
!=
[
1
]
*
len
(
self
.
_dilation
):
if
self
.
_dilation
!=
[
1
]
*
len
(
self
.
_dilation
):
main_str
+=
', dilation={_dilation}'
main_str
+=
', dilation={_dilation}'
if
self
.
_groups
!=
1
:
if
self
.
_groups
!=
1
:
...
@@ -508,7 +508,7 @@ class Conv1DTranspose(_ConvNd):
...
@@ -508,7 +508,7 @@ class Conv1DTranspose(_ConvNd):
self
.
weight
,
self
.
weight
,
bias
=
self
.
bias
,
bias
=
self
.
bias
,
output_size
=
output_size
,
output_size
=
output_size
,
output_padding
=
self
.
_
output_padding
,
output_padding
=
self
.
output_padding
,
padding
=
self
.
_padding
,
padding
=
self
.
_padding
,
stride
=
self
.
_stride
,
stride
=
self
.
_stride
,
dilation
=
self
.
_dilation
,
dilation
=
self
.
_dilation
,
...
@@ -824,7 +824,7 @@ class Conv2DTranspose(_ConvNd):
...
@@ -824,7 +824,7 @@ class Conv2DTranspose(_ConvNd):
def
forward
(
self
,
x
,
output_size
=
None
):
def
forward
(
self
,
x
,
output_size
=
None
):
if
output_size
is
None
:
if
output_size
is
None
:
output_padding
=
self
.
_
output_padding
output_padding
=
self
.
output_padding
else
:
else
:
output_padding
=
0
output_padding
=
0
...
@@ -1161,7 +1161,7 @@ class Conv3DTranspose(_ConvNd):
...
@@ -1161,7 +1161,7 @@ class Conv3DTranspose(_ConvNd):
def
forward
(
self
,
x
,
output_size
=
None
):
def
forward
(
self
,
x
,
output_size
=
None
):
if
output_size
is
None
:
if
output_size
is
None
:
output_padding
=
self
.
_
output_padding
output_padding
=
self
.
output_padding
else
:
else
:
output_padding
=
0
output_padding
=
0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录