Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
24c7087f
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
24c7087f
编写于
7月 22, 2021
作者:
W
wangguanzhong
提交者:
GitHub
7月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix index erro in conv2d_transpose (#34270)
上级
82339ed1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
1 deletion
+31
-1
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+12
-1
python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
.../paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
+19
-0
未找到文件。
python/paddle/fluid/layers/nn.py
浏览文件 @
24c7087f
...
@@ -3924,6 +3924,10 @@ def conv2d_transpose(input,
...
@@ -3924,6 +3924,10 @@ def conv2d_transpose(input,
print(conv2d_transpose.shape) # [-1, 2, 34, 34]
print(conv2d_transpose.shape) # [-1, 2, 34, 34]
"""
"""
assert param_attr is not False, "param_attr should not be False in conv2d_transpose."
assert param_attr is not False, "param_attr should not be False in conv2d_transpose."
if len(input.shape) != 4:
raise ValueError("Input size should be 4, "
"but received {}".format(len(input.shape)))
if data_format not in ['NCHW', 'NHWC']:
if data_format not in ['NCHW', 'NHWC']:
raise ValueError(
raise ValueError(
"Attr(data_format) of Op(fluid.layers.conv2d_transpose) got wrong value: received "
"Attr(data_format) of Op(fluid.layers.conv2d_transpose) got wrong value: received "
...
@@ -4015,7 +4019,14 @@ def conv2d_transpose(input,
...
@@ -4015,7 +4019,14 @@ def conv2d_transpose(input,
output_size = utils.convert_to_list(output_size, 2, 'output_size')
output_size = utils.convert_to_list(output_size, 2, 'output_size')
else:
else:
raise ValueError("output_size should be int, list[int] or tuple[int]")
raise ValueError("output_size should be int, list[int] or tuple[int]")
groups = 1 if groups is None else groups
if groups is None:
groups = 1
elif groups <= 0:
raise ValueError("the groups of input must be greater than 0, "
"but received the groups of input is {}".format(
groups))
filter_shape = [input_channel, num_filters // groups] + filter_size
filter_shape = [input_channel, num_filters // groups] + filter_size
img_filter = helper.create_parameter(
img_filter = helper.create_parameter(
...
...
python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
浏览文件 @
24c7087f
...
@@ -898,6 +898,25 @@ class TestConv2DTransposeOpException(unittest.TestCase):
...
@@ -898,6 +898,25 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
attr_padding_with_data_format
)
self
.
assertRaises
(
ValueError
,
attr_padding_with_data_format
)
error_input
=
fluid
.
layers
.
data
(
name
=
'error_data'
,
shape
=
[
1
],
dtype
=
"float32"
)
def
error_input_size
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
error_input
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
)
self
.
assertRaises
(
ValueError
,
error_input_size
)
def
error_groups
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
0
,
num_filters
=
6
,
filter_size
=
3
,
data_format
=
'NHWC'
)
self
.
assertRaises
(
ValueError
,
error_groups
)
class
TestConv2DTransposeRepr
(
unittest
.
TestCase
):
class
TestConv2DTransposeRepr
(
unittest
.
TestCase
):
def
test_case
(
self
):
def
test_case
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录