Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3f734f94
提交
3f734f94
authored
9月 18, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify how atol and rtol are determined.
上级
ef9e88ed
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
29 行增加
和
23 行删除
+29
-23
type.py
theano/sandbox/gpuarray/type.py
+1
-7
basic.py
theano/tensor/basic.py
+27
-7
unittest_tools.py
theano/tests/unittest_tools.py
+1
-9
没有找到文件。
theano/sandbox/gpuarray/type.py
浏览文件 @
3f734f94
...
...
@@ -162,13 +162,7 @@ class GpuArrayType(Type):
return
tensor
.
TensorType
.
values_eq_approx
(
an
,
bn
,
allow_remove_inf
=
allow_remove_inf
,
allow_remove_nan
=
allow_remove_nan
,
rtol
=
rtol
,
atol
=
atol
)
narrow
=
'float32'
,
'complex64'
if
(
str
(
a
.
dtype
)
in
narrow
)
or
(
str
(
b
.
dtype
)
in
narrow
):
atol_
=
theano
.
tensor
.
basic
.
float32_atol
rtol_
=
theano
.
tensor
.
basic
.
float32_rtol
else
:
atol_
=
theano
.
tensor
.
basic
.
float64_atol
rtol_
=
theano
.
tensor
.
basic
.
float64_rtol
atol_
,
rtol_
=
theano
.
tensor
.
basic
.
_get_atol_rtol
(
a
,
b
)
if
rtol
is
not
None
:
rtol_
=
rtol
if
atol
is
not
None
:
...
...
theano/tensor/basic.py
浏览文件 @
3f734f94
...
...
@@ -459,18 +459,29 @@ if int(config.tensor.cmp_sloppy) > 1:
# When config.tensor.cmp_sloppy>1 we are even more sloppy. This is
# useful to test the GPU as they don't use extended precision and
# this cause some difference bigger then the normal sloppy.
float16_atol
=
5e-3
float16_rtol
=
1e-2
float32_atol
=
5e-4
float32_rtol
=
1e-3
float64_rtol
=
1e-4
float64_atol
=
1e-3
elif
int
(
config
.
tensor
.
cmp_sloppy
):
float16_atol
=
1e-3
float16_rtol
=
5e-3
float32_atol
=
1e-4
float32_rtol
=
1e-3
float64_rtol
=
1e-4
float64_atol
=
1e-3
else
:
# If you change those value in test don't forget to put them back
# when the test end. Don't forget the case when the test fail.
float16_atol
=
5e-4
float16_rtol
=
5e-4
float32_atol
=
1e-5
float32_rtol
=
1e-5
...
...
@@ -481,16 +492,25 @@ else:
float64_rtol
=
1.0000000000000001e-06
def
_get_atol_rtol
(
a
,
b
):
tiny
=
(
'float16'
,)
narrow
=
(
'float32'
,
'complex64'
)
if
(
str
(
a
.
dtype
)
in
tiny
)
or
(
str
(
b
.
dtype
)
in
tiny
):
atol
=
float16_atol
rtol
=
float16_rtol
elif
(
str
(
a
.
dtype
)
in
narrow
)
or
(
str
(
b
.
dtype
)
in
narrow
):
atol
=
float32_atol
rtol
=
float32_rtol
else
:
atol
=
float64_atol
rtol
=
float64_rtol
return
atol
,
rtol
def
_allclose
(
a
,
b
,
rtol
=
None
,
atol
=
None
):
a
=
numpy
.
asarray
(
a
)
b
=
numpy
.
asarray
(
b
)
narrow
=
'float32'
,
'complex64'
if
(
str
(
a
.
dtype
)
in
narrow
)
or
(
str
(
b
.
dtype
)
in
narrow
):
atol_
=
float32_atol
rtol_
=
float32_rtol
else
:
atol_
=
float64_atol
rtol_
=
float64_rtol
atol_
,
rtol_
=
_get_atol_rtol
(
a
,
b
)
if
rtol
is
not
None
:
rtol_
=
rtol
if
atol
is
not
None
:
...
...
theano/tests/unittest_tools.py
浏览文件 @
3f734f94
...
...
@@ -309,15 +309,7 @@ def str_diagnostic(expected, value, rtol, atol):
print
(
ssio
.
getvalue
(),
file
=
sio
)
except
Exception
:
pass
# Use the same formula as in _allclose to find the tolerance used
narrow
=
'float32'
,
'complex64'
if
((
str
(
expected
.
dtype
)
in
narrow
)
or
(
str
(
value
.
dtype
)
in
narrow
)):
atol_
=
T
.
basic
.
float32_atol
rtol_
=
T
.
basic
.
float32_rtol
else
:
atol_
=
T
.
basic
.
float64_atol
rtol_
=
T
.
basic
.
float64_rtol
atol_
,
rtol_
=
T
.
basic
.
_get_atol_rtol
(
expected
,
value
)
if
rtol
is
not
None
:
rtol_
=
rtol
if
atol
is
not
None
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论