Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
cfcc45d9
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cfcc45d9
编写于
9月 23, 2020
作者:
P
pangyoki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
increase tolerance
上级
c0caf0e4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
6 addition
and
6 deletion
+6
-6
python/paddle/fluid/tests/unittests/test_distribution.py
python/paddle/fluid/tests/unittests/test_distribution.py
+6
-6
未找到文件。
python/paddle/fluid/tests/unittests/test_distribution.py
浏览文件 @
cfcc45d9
...
@@ -138,7 +138,7 @@ class UniformTest(unittest.TestCase):
...
@@ -138,7 +138,7 @@ class UniformTest(unittest.TestCase):
self
.
static_values
=
layers
.
data
(
self
.
static_values
=
layers
.
data
(
name
=
'values'
,
shape
=
[],
dtype
=
'float32'
)
name
=
'values'
,
shape
=
[],
dtype
=
'float32'
)
def
compare_with_numpy
(
self
,
fetch_list
,
sample_shape
=
7
,
tolerance
=
1e-
6
):
def
compare_with_numpy
(
self
,
fetch_list
,
sample_shape
=
7
,
tolerance
=
1e-
4
):
sample
,
entropy
,
log_prob
,
probs
=
fetch_list
sample
,
entropy
,
log_prob
,
probs
=
fetch_list
np_uniform
=
UniformNumpy
(
self
.
low_np
,
self
.
high_np
)
np_uniform
=
UniformNumpy
(
self
.
low_np
,
self
.
high_np
)
...
@@ -154,7 +154,7 @@ class UniformTest(unittest.TestCase):
...
@@ -154,7 +154,7 @@ class UniformTest(unittest.TestCase):
log_prob
,
np_lp
,
rtol
=
tolerance
,
atol
=
tolerance
)
log_prob
,
np_lp
,
rtol
=
tolerance
,
atol
=
tolerance
)
np
.
testing
.
assert_allclose
(
probs
,
np_p
,
rtol
=
tolerance
,
atol
=
tolerance
)
np
.
testing
.
assert_allclose
(
probs
,
np_p
,
rtol
=
tolerance
,
atol
=
tolerance
)
def
test_uniform_distribution_dygraph
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
6
):
def
test_uniform_distribution_dygraph
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
4
):
paddle
.
disable_static
(
self
.
place
)
paddle
.
disable_static
(
self
.
place
)
uniform
=
Uniform
(
self
.
dynamic_low
,
self
.
dynamic_high
)
uniform
=
Uniform
(
self
.
dynamic_low
,
self
.
dynamic_high
)
sample
=
uniform
.
sample
([
sample_shape
]).
numpy
()
sample
=
uniform
.
sample
([
sample_shape
]).
numpy
()
...
@@ -165,7 +165,7 @@ class UniformTest(unittest.TestCase):
...
@@ -165,7 +165,7 @@ class UniformTest(unittest.TestCase):
self
.
compare_with_numpy
(
fetch_list
)
self
.
compare_with_numpy
(
fetch_list
)
def
test_uniform_distribution_static
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
6
):
def
test_uniform_distribution_static
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
4
):
paddle
.
enable_static
()
paddle
.
enable_static
()
with
fluid
.
program_guard
(
self
.
test_program
):
with
fluid
.
program_guard
(
self
.
test_program
):
uniform
=
Uniform
(
self
.
static_low
,
self
.
static_high
)
uniform
=
Uniform
(
self
.
static_low
,
self
.
static_high
)
...
@@ -368,7 +368,7 @@ class NormalTest(unittest.TestCase):
...
@@ -368,7 +368,7 @@ class NormalTest(unittest.TestCase):
self
.
static_values
=
layers
.
data
(
self
.
static_values
=
layers
.
data
(
name
=
'values'
,
shape
=
[],
dtype
=
'float32'
)
name
=
'values'
,
shape
=
[],
dtype
=
'float32'
)
def
compare_with_numpy
(
self
,
fetch_list
,
sample_shape
=
7
,
tolerance
=
1e-
6
):
def
compare_with_numpy
(
self
,
fetch_list
,
sample_shape
=
7
,
tolerance
=
1e-
4
):
sample
,
entropy
,
log_prob
,
probs
,
kl
=
fetch_list
sample
,
entropy
,
log_prob
,
probs
,
kl
=
fetch_list
np_normal
=
NormalNumpy
(
self
.
loc_np
,
self
.
scale_np
)
np_normal
=
NormalNumpy
(
self
.
loc_np
,
self
.
scale_np
)
...
@@ -387,7 +387,7 @@ class NormalTest(unittest.TestCase):
...
@@ -387,7 +387,7 @@ class NormalTest(unittest.TestCase):
np
.
testing
.
assert_allclose
(
probs
,
np_p
,
rtol
=
tolerance
,
atol
=
tolerance
)
np
.
testing
.
assert_allclose
(
probs
,
np_p
,
rtol
=
tolerance
,
atol
=
tolerance
)
np
.
testing
.
assert_allclose
(
kl
,
np_kl
,
rtol
=
tolerance
,
atol
=
tolerance
)
np
.
testing
.
assert_allclose
(
kl
,
np_kl
,
rtol
=
tolerance
,
atol
=
tolerance
)
def
test_normal_distribution_dygraph
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
6
):
def
test_normal_distribution_dygraph
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
4
):
paddle
.
disable_static
(
self
.
place
)
paddle
.
disable_static
(
self
.
place
)
normal
=
Normal
(
self
.
dynamic_loc
,
self
.
dynamic_scale
)
normal
=
Normal
(
self
.
dynamic_loc
,
self
.
dynamic_scale
)
...
@@ -401,7 +401,7 @@ class NormalTest(unittest.TestCase):
...
@@ -401,7 +401,7 @@ class NormalTest(unittest.TestCase):
fetch_list
=
[
sample
,
entropy
,
log_prob
,
probs
,
kl
]
fetch_list
=
[
sample
,
entropy
,
log_prob
,
probs
,
kl
]
self
.
compare_with_numpy
(
fetch_list
)
self
.
compare_with_numpy
(
fetch_list
)
def
test_normal_distribution_static
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
6
):
def
test_normal_distribution_static
(
self
,
sample_shape
=
7
,
tolerance
=
1e-
4
):
paddle
.
enable_static
()
paddle
.
enable_static
()
with
fluid
.
program_guard
(
self
.
test_program
):
with
fluid
.
program_guard
(
self
.
test_program
):
normal
=
Normal
(
self
.
static_loc
,
self
.
static_scale
)
normal
=
Normal
(
self
.
static_loc
,
self
.
static_scale
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录