Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
82ec247a
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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看板
未验证
提交
82ec247a
编写于
7月 01, 2020
作者:
A
Aurelius84
提交者:
GitHub
7月 01, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix random failed on GPU test=develop (#25293)
上级
0371cf6f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
1 deletion
+20
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cycle_gan.py
...fluid/tests/unittests/dygraph_to_static/test_cycle_gan.py
+20
-1
未找到文件。
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cycle_gan.py
浏览文件 @
82ec247a
...
@@ -32,6 +32,10 @@ import unittest
...
@@ -32,6 +32,10 @@ import unittest
import
numpy
as
np
import
numpy
as
np
from
PIL
import
Image
,
ImageOps
from
PIL
import
Image
,
ImageOps
import
os
# Use GPU:0 to elimate the influence of other tasks.
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
"1"
import
paddle
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
paddle.fluid.dygraph
import
to_variable
,
declarative
,
ProgramTranslator
from
paddle.fluid.dygraph
import
to_variable
,
declarative
,
ProgramTranslator
...
@@ -327,6 +331,11 @@ class conv2d(fluid.dygraph.Layer):
...
@@ -327,6 +331,11 @@ class conv2d(fluid.dygraph.Layer):
initializer
=
fluid
.
initializer
.
NormalInitializer
(
initializer
=
fluid
.
initializer
.
NormalInitializer
(
loc
=
0.0
,
scale
=
stddev
)),
loc
=
0.0
,
scale
=
stddev
)),
bias_attr
=
con_bias_attr
)
bias_attr
=
con_bias_attr
)
# Note(Aurelius84): The calculation of GPU kernel in BN is non-deterministic,
# failure rate is 1/100 in Dev but seems incremental in CE platform.
# If on GPU, we disable BN temporarily.
if
fluid
.
is_compiled_with_cuda
():
norm
=
False
if
norm
:
if
norm
:
self
.
bn
=
BatchNorm
(
self
.
bn
=
BatchNorm
(
use_global_stats
=
True
,
# set True to use deterministic algorithm
use_global_stats
=
True
,
# set True to use deterministic algorithm
...
@@ -383,6 +392,8 @@ class DeConv2D(fluid.dygraph.Layer):
...
@@ -383,6 +392,8 @@ class DeConv2D(fluid.dygraph.Layer):
initializer
=
fluid
.
initializer
.
NormalInitializer
(
initializer
=
fluid
.
initializer
.
NormalInitializer
(
loc
=
0.0
,
scale
=
stddev
)),
loc
=
0.0
,
scale
=
stddev
)),
bias_attr
=
de_bias_attr
)
bias_attr
=
de_bias_attr
)
if
fluid
.
is_compiled_with_cuda
():
norm
=
False
if
norm
:
if
norm
:
self
.
bn
=
BatchNorm
(
self
.
bn
=
BatchNorm
(
use_global_stats
=
True
,
# set True to use deterministic algorithm
use_global_stats
=
True
,
# set True to use deterministic algorithm
...
@@ -606,8 +617,16 @@ class TestCycleGANModel(unittest.TestCase):
...
@@ -606,8 +617,16 @@ class TestCycleGANModel(unittest.TestCase):
def
test_train
(
self
):
def
test_train
(
self
):
st_out
=
self
.
train
(
to_static
=
True
)
st_out
=
self
.
train
(
to_static
=
True
)
dy_out
=
self
.
train
(
to_static
=
False
)
dy_out
=
self
.
train
(
to_static
=
False
)
assert_func
=
np
.
allclose
# Note(Aurelius84): Because we disable BN on GPU,
# but here we enhance the check on CPU by `np.array_equal`
# which means the dy_out and st_out shall be exactly same.
if
not
fluid
.
is_compiled_with_cuda
():
assert_func
=
np
.
array_equal
self
.
assertTrue
(
self
.
assertTrue
(
np
.
allclose
(
dy_out
,
st_out
),
assert_func
(
dy_out
,
st_out
),
msg
=
"dy_out:
\n
{}
\n
st_out:
\n
{}"
.
format
(
dy_out
,
st_out
))
msg
=
"dy_out:
\n
{}
\n
st_out:
\n
{}"
.
format
(
dy_out
,
st_out
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录