Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
604709ed
提交
604709ed
authored
5月 09, 2016
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add checking for inputs in new NanGuardMode.
上级
530f442a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
22 行删除
+16
-22
nanguardmode.py
theano/compile/nanguardmode.py
+16
-22
没有找到文件。
theano/compile/nanguardmode.py
浏览文件 @
604709ed
...
...
@@ -71,7 +71,7 @@ def contains_nan(arr, node=None):
elif
arr
.
size
==
0
:
return
False
elif
cuda
.
cuda_available
and
isinstance
(
arr
,
cuda
.
CudaNdarray
):
if
(
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
if
(
node
and
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
isinstance
(
node
.
op
,
# It store ints in float container
...
...
@@ -115,7 +115,7 @@ def contains_inf(arr, node=None):
elif
arr
.
size
==
0
:
return
False
elif
cuda
.
cuda_available
and
isinstance
(
arr
,
cuda
.
CudaNdarray
):
if
(
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
if
(
node
and
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
isinstance
(
node
.
op
,
# It store ints in float container
...
...
@@ -251,10 +251,14 @@ class NanGuardMode(Mode):
print
(
'Big value detected'
,
file
=
sio
)
error
=
True
if
error
:
print
(
"NanGuardMode found an error in the"
" output of a node in this variable:"
,
file
=
sio
)
print
(
theano
.
printing
.
debugprint
(
nd
,
file
=
'str'
),
file
=
sio
)
msg
=
sio
.
getvalue
()
if
nd
:
print
(
"NanGuardMode found an error in the "
"output of a node in this variable:"
,
file
=
sio
)
print
(
theano
.
printing
.
debugprint
(
nd
,
file
=
'str'
),
file
=
sio
)
msg
=
sio
.
getvalue
()
else
:
print
(
"NanGuardMode found an error in an input of the "
"graph."
,
file
=
sio
)
if
config
.
NanGuardMode
.
action
==
'raise'
:
raise
AssertionError
(
msg
)
elif
config
.
NanGuardMode
.
action
==
'pdb'
:
...
...
@@ -265,25 +269,15 @@ class NanGuardMode(Mode):
logger
.
error
(
msg
)
def
nan_check
(
node
,
thunk
,
storage_map
,
compute_map
):
"""
Runs `fn` while checking its inputs and outputs for NaNs / Infs.
Parameters
----------
node : theano.gof.Apply
The Apply node currently being executed.
thunk : callable
The thunk to execute for this Apply node.
storage_map : dict
The mapping of variables to storage cells.
compute_map : dict
The mapping to get the computed state of the nodes. (ignored)
"""
for
var
in
node
.
outputs
:
if
getattr
(
var
.
tag
,
'nan_guard_mode_check'
,
True
):
do_check_on
(
storage_map
[
var
][
0
],
node
)
wrap_linker
=
theano
.
gof
.
vm
.
VM_Linker
(
callback
=
nan_check
)
def
nan_check_input
(
var
,
value
):
if
getattr
(
var
.
tag
,
'nan_guard_mode_check'
,
True
):
do_check_on
(
value
,
None
)
wrap_linker
=
theano
.
gof
.
vm
.
VM_Linker
(
callback
=
nan_check
,
callback_input
=
nan_check_input
)
super
(
NanGuardMode
,
self
)
.
__init__
(
wrap_linker
,
optimizer
=
self
.
provided_optimizer
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论