Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f97b10df
提交
f97b10df
authored
8月 03, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test crash and now NanGuardMode print the stack trace on inputs of the graph.
上级
444fa022
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
15 行删除
+20
-15
nanguardmode.py
theano/compile/nanguardmode.py
+20
-15
没有找到文件。
theano/compile/nanguardmode.py
浏览文件 @
f97b10df
...
...
@@ -215,44 +215,47 @@ class NanGuardMode(Mode):
assert
nan_is_error
or
inf_is_error
or
big_is_error
compile_gpu_func
(
nan_is_error
,
inf_is_error
,
big_is_error
)
def
do_check_on
(
va
r
,
nd
):
def
do_check_on
(
va
lue
,
nd
,
var
=
None
):
"""
Checks `va
r
` for NaNs / Infs. If detected, raises an exception
Checks `va
lue
` for NaNs / Infs. If detected, raises an exception
and / or prints information about `nd`, `f`, and `is_input` to
help the user determine the cause of the invalid values.
Parameters
----------
va
r
: numpy.ndarray
va
lue
: numpy.ndarray
The value to be checked.
nd : theano.gof.Apply
The Apply node being executed.
var : theano.gof.Variable
Not used if nd is there. Otherwise, used to print the stack
trace for inputs of the graph.
"""
error
=
False
sio
=
StringIO
()
if
nan_is_error
:
if
contains_nan
(
va
r
,
nd
):
if
contains_nan
(
va
lue
,
nd
):
print
(
'NaN detected'
,
file
=
sio
)
error
=
True
if
inf_is_error
:
if
contains_inf
(
va
r
,
nd
):
if
contains_inf
(
va
lue
,
nd
):
print
(
'Inf detected'
,
file
=
sio
)
error
=
True
if
big_is_error
:
err
=
False
if
isinstance
(
va
r
,
theano
.
gof
.
type
.
CDataType
.
_cdata_type
):
if
isinstance
(
va
lue
,
theano
.
gof
.
type
.
CDataType
.
_cdata_type
):
err
=
False
elif
isinstance
(
va
r
,
np
.
random
.
mtrand
.
RandomState
):
elif
isinstance
(
va
lue
,
np
.
random
.
mtrand
.
RandomState
):
err
=
False
elif
isinstance
(
va
r
,
slice
):
elif
isinstance
(
va
lue
,
slice
):
err
=
False
elif
va
r
.
size
==
0
:
elif
va
lue
.
size
==
0
:
err
=
False
elif
cuda
.
cuda_available
and
isinstance
(
va
r
,
cuda
.
CudaNdarray
):
err
=
(
f_gpuabsmax
(
va
r
.
reshape
(
var
.
size
))
>
1e10
)
elif
cuda
.
cuda_available
and
isinstance
(
va
lue
,
cuda
.
CudaNdarray
):
err
=
(
f_gpuabsmax
(
va
lue
.
reshape
(
value
.
size
))
>
1e10
)
else
:
err
=
(
np
.
abs
(
va
r
)
.
max
()
>
1e10
)
err
=
(
np
.
abs
(
va
lue
)
.
max
()
>
1e10
)
if
err
:
print
(
'Big value detected'
,
file
=
sio
)
error
=
True
...
...
@@ -265,8 +268,10 @@ class NanGuardMode(Mode):
print
(
"NanGuardMode found an error in an input of the "
"graph."
,
file
=
sio
)
# Add the stack trace
print
(
theano
.
gof
.
utils
.
get_variable_trace_string
(
nd
.
outputs
[
0
]),
file
=
sio
)
if
nd
:
var
=
nd
.
outputs
[
0
]
print
(
theano
.
gof
.
utils
.
get_variable_trace_string
(
var
),
file
=
sio
)
msg
=
sio
.
getvalue
()
if
config
.
NanGuardMode
.
action
==
'raise'
:
raise
AssertionError
(
msg
)
...
...
@@ -284,7 +289,7 @@ class NanGuardMode(Mode):
def
nan_check_input
(
var
,
value
):
if
getattr
(
var
.
tag
,
'nan_guard_mode_check'
,
True
):
do_check_on
(
value
,
None
)
do_check_on
(
value
,
None
,
var
=
var
)
wrap_linker
=
theano
.
gof
.
vm
.
VM_Linker
(
callback
=
nan_check
,
callback_input
=
nan_check_input
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论