Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yushenjjy
Paddle
提交
75a17cdb
P
Paddle
项目概览
yushenjjy
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
75a17cdb
编写于
4月 04, 2022
作者:
Z
Zhanlue Yang
提交者:
GitHub
4月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Skip DoubleGrad-related unit tests under eager mode (#41380)
上级
5b8c5b7b
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
168 addition
and
60 deletion
+168
-60
python/paddle/fluid/tests/unittests/autograd/test_autograd_functional_dynamic.py
...ts/unittests/autograd/test_autograd_functional_dynamic.py
+149
-56
python/paddle/fluid/tests/unittests/test_imperative_star_gan_with_gradient_penalty.py
...ittests/test_imperative_star_gan_with_gradient_penalty.py
+6
-1
python/paddle/fluid/tests/unittests/test_imperative_triple_grad.py
...ddle/fluid/tests/unittests/test_imperative_triple_grad.py
+13
-3
未找到文件。
python/paddle/fluid/tests/unittests/autograd/test_autograd_functional_dynamic.py
浏览文件 @
75a17cdb
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_imperative_star_gan_with_gradient_penalty.py
浏览文件 @
75a17cdb
...
...
@@ -17,6 +17,7 @@ import paddle.fluid as fluid
import
numpy
as
np
import
unittest
from
paddle
import
_C_ops
from
paddle.fluid.framework
import
_test_eager_guard
,
_in_legacy_dygraph
,
_in_eager_without_dygraph_check
if
fluid
.
is_compiled_with_cuda
():
fluid
.
core
.
globals
()[
'FLAGS_cudnn_deterministic'
]
=
True
...
...
@@ -583,7 +584,7 @@ class StaticGraphTrainModel(object):
class
TestStarGANWithGradientPenalty
(
unittest
.
TestCase
):
def
test
_main
(
self
):
def
func
_main
(
self
):
self
.
place_test
(
fluid
.
CPUPlace
())
if
fluid
.
is_compiled_with_cuda
():
...
...
@@ -615,6 +616,10 @@ class TestStarGANWithGradientPenalty(unittest.TestCase):
self
.
assertEqual
(
g_loss_s
,
g_loss_d
)
self
.
assertEqual
(
d_loss_s
,
d_loss_d
)
def
test_all_cases
(
self
):
if
_in_legacy_dygraph
():
self
.
func_main
()
if
__name__
==
'__main__'
:
paddle
.
enable_static
()
...
...
python/paddle/fluid/tests/unittests/test_imperative_triple_grad.py
浏览文件 @
75a17cdb
...
...
@@ -19,6 +19,7 @@ from paddle.vision.models import resnet50, resnet101
import
unittest
from
unittest
import
TestCase
import
numpy
as
np
from
paddle.fluid.framework
import
_test_eager_guard
,
_in_legacy_dygraph
,
_in_eager_without_dygraph_check
def
_dygraph_guard_
(
func
):
...
...
@@ -65,7 +66,7 @@ class TestDygraphTripleGrad(TestCase):
allow_unused
=
allow_unused
)
@
dygraph_guard
def
test
_exception
(
self
):
def
func
_exception
(
self
):
with
self
.
assertRaises
(
AssertionError
):
self
.
grad
(
None
,
None
)
...
...
@@ -95,7 +96,7 @@ class TestDygraphTripleGrad(TestCase):
self
.
grad
([
random_var
(
shape
)],
[
random_var
(
shape
)],
no_grad_vars
=
1
)
@
dygraph_guard
def
test
_example_with_gradient_and_create_graph
(
self
):
def
func
_example_with_gradient_and_create_graph
(
self
):
x
=
random_var
(
self
.
shape
)
x_np
=
x
.
numpy
()
x
.
stop_gradient
=
False
...
...
@@ -145,6 +146,11 @@ class TestDygraphTripleGrad(TestCase):
dddx_grad_actual
=
x
.
gradient
()
self
.
assertTrue
(
np
.
allclose
(
dddx_grad_actual
,
dddx_expected
))
def
test_all_cases
(
self
):
if
_in_legacy_dygraph
():
self
.
func_exception
()
self
.
func_example_with_gradient_and_create_graph
()
class
TestDygraphTripleGradBradcastCase
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -172,7 +178,7 @@ class TestDygraphTripleGradBradcastCase(TestCase):
allow_unused
=
allow_unused
)
@
dygraph_guard
def
test
_example_with_gradient_and_create_graph
(
self
):
def
func
_example_with_gradient_and_create_graph
(
self
):
x
=
random_var
(
self
.
x_shape
)
x_np
=
x
.
numpy
()
x
.
stop_gradient
=
False
...
...
@@ -227,6 +233,10 @@ class TestDygraphTripleGradBradcastCase(TestCase):
dddx_grad_actual
=
x
.
gradient
()
self
.
assertTrue
(
np
.
allclose
(
dddx_grad_actual
,
dddx_expected
))
def
test_all_cases
(
self
):
if
_in_legacy_dygraph
():
self
.
func_example_with_gradient_and_create_graph
()
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录