Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c16345cb
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
c16345cb
编写于
5月 11, 2022
作者:
C
chentianyu03
提交者:
GitHub
5月 11, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Yaml]add Double grad (#42638)
* add conv2d_transpose_double_grad yaml * add test_conv_transpose double_grad test case
上级
3ac9e754
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
0 deletion
+55
-0
python/paddle/fluid/tests/unittests/test_conv_transpose_nn_grad.py
...ddle/fluid/tests/unittests/test_conv_transpose_nn_grad.py
+44
-0
python/paddle/utils/code_gen/backward.yaml
python/paddle/utils/code_gen/backward.yaml
+11
-0
未找到文件。
python/paddle/fluid/tests/unittests/test_conv_transpose_nn_grad.py
浏览文件 @
c16345cb
...
...
@@ -27,6 +27,9 @@ from decorator_helper import prog_scope
class
TestConvTransposeDoubleGradCheck
(
unittest
.
TestCase
):
def
conv_transpose_wrapper
(
self
,
x
):
return
paddle
.
nn
.
functional
.
conv2d_transpose
(
x
[
0
],
x
[
1
],
groups
=
1
)
@
prog_scope
()
def
func
(
self
,
place
):
shape
=
[
2
,
4
,
3
,
3
]
...
...
@@ -55,6 +58,11 @@ class TestConvTransposeDoubleGradCheck(unittest.TestCase):
else
:
gradient_checker
.
double_grad_check
(
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
,
eps
=
eps
)
gradient_checker
.
double_grad_check_for_dygraph
(
self
.
conv_transpose_wrapper
,
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
)
def
test_grad
(
self
):
places
=
[]
...
...
@@ -67,6 +75,10 @@ class TestConvTransposeDoubleGradCheck(unittest.TestCase):
class
TestConvTranspose2DoubleGradCheck_AsyPadding
(
TestConvTransposeDoubleGradCheck
):
def
conv_transpose_wrapper
(
self
,
x
):
return
paddle
.
nn
.
functional
.
conv2d_transpose
(
x
[
0
],
x
[
1
],
groups
=
1
,
padding
=
[
1
,
0
,
0
,
1
])
@
prog_scope
()
def
func
(
self
,
place
):
shape
=
[
2
,
2
,
3
,
3
]
...
...
@@ -100,10 +112,19 @@ class TestConvTranspose2DoubleGradCheck_AsyPadding(
else
:
gradient_checker
.
double_grad_check
(
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
,
eps
=
eps
)
gradient_checker
.
double_grad_check_for_dygraph
(
self
.
conv_transpose_wrapper
,
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
)
class
TestConvTranspose2DoubleGradCheck_PaddingSAME
(
TestConvTransposeDoubleGradCheck
):
def
conv_transpose_wrapper
(
self
,
x
):
return
paddle
.
nn
.
functional
.
conv2d_transpose
(
x
[
0
],
x
[
1
],
groups
=
1
,
padding
=
"SAME"
)
@
prog_scope
()
def
func
(
self
,
place
):
shape
=
[
2
,
2
,
3
,
3
]
...
...
@@ -137,10 +158,19 @@ class TestConvTranspose2DoubleGradCheck_PaddingSAME(
else
:
gradient_checker
.
double_grad_check
(
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
,
eps
=
eps
)
gradient_checker
.
double_grad_check_for_dygraph
(
self
.
conv_transpose_wrapper
,
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
)
class
TestConvTranspose2DoubleGradCheck_PaddingVALID
(
TestConvTransposeDoubleGradCheck
):
def
conv_transpose_wrapper
(
self
,
x
):
return
paddle
.
nn
.
functional
.
conv2d_transpose
(
x
[
0
],
x
[
1
],
groups
=
1
,
padding
=
"VALID"
)
@
prog_scope
()
def
func
(
self
,
place
):
shape
=
[
2
,
2
,
3
,
3
]
...
...
@@ -174,10 +204,19 @@ class TestConvTranspose2DoubleGradCheck_PaddingVALID(
else
:
gradient_checker
.
double_grad_check
(
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
,
eps
=
eps
)
gradient_checker
.
double_grad_check_for_dygraph
(
self
.
conv_transpose_wrapper
,
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
)
class
TestConvTranspose2DoubleGradCheck_ChannelLast
(
TestConvTransposeDoubleGradCheck
):
def
conv_transpose_wrapper
(
self
,
x
):
return
paddle
.
nn
.
functional
.
conv2d_transpose
(
x
[
0
],
x
[
1
],
groups
=
1
,
padding
=
[
1
,
1
],
data_format
=
"NHWC"
)
@
prog_scope
()
def
func
(
self
,
place
):
shape
=
[
2
,
3
,
3
,
2
]
...
...
@@ -213,6 +252,11 @@ class TestConvTranspose2DoubleGradCheck_ChannelLast(
else
:
gradient_checker
.
double_grad_check
(
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
,
eps
=
eps
)
gradient_checker
.
double_grad_check_for_dygraph
(
self
.
conv_transpose_wrapper
,
[
x
]
+
w
,
y
,
x_init
=
[
x_arr
]
+
w_arr
,
place
=
place
)
if
__name__
==
"__main__"
:
...
...
python/paddle/utils/code_gen/backward.yaml
浏览文件 @
c16345cb
...
...
@@ -301,6 +301,16 @@
use_gpudnn
:
true
optional
:
grad_input_grad, grad_filter_grad
-
backward_api
:
conv2d_transpose_double_grad
forward
:
conv2d_transpose_grad(Tensor x, Tensor filter, Tensor grad_out, int[] strides, int[] paddings, int[] output_padding, int[] output_size, str padding_algorithm, int groups, int[] dilations, str data_format) -> Tensor(grad_x), Tensor(grad_filter)
args
:
(Tensor x, Tensor filter, Tensor grad_out, Tensor grad_x_grad, Tensor grad_filter_grad, int[] strides, int[] paddings, int[] output_padding, int[] output_size, str padding_algorithm, int groups, int[] dilations, str data_format)
output
:
Tensor(x_grad), Tensor(filter_grad), Tensor(grad_out_grad)
infer_meta
:
func
:
Conv2dTransposeDoubleGradInferMeta
kernel
:
func
:
conv2d_transpose_grad_grad
use_gpudnn
:
true
-
backward_api
:
conv2d_transpose_grad
forward
:
conv2d_transpose(Tensor x, Tensor filter, int[] strides, int[] paddings, int[] output_padding, int[] output_size, str padding_algorithm, int groups, int[] dilations, str data_format) -> Tensor(out)
args
:
(Tensor x, Tensor filter, Tensor out_grad, int[] strides, int[] paddings, int[] output_padding, int[] output_size, str padding_algorithm, int groups, int[] dilations, str data_format)
...
...
@@ -310,6 +320,7 @@
kernel
:
func
:
conv2d_transpose_grad
use_gpudnn
:
true
backward
:
conv2d_transpose_double_grad
-
backward_api
:
conv3d_transpose_grad
forward
:
conv3d_transpose(Tensor x, Tensor filter, int[] strides, int[] paddings, int[] output_padding, int[] output_size, str padding_algorithm, int groups, int[] dilations, str data_format) -> Tensor(out)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录