Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
49590e13
提交
49590e13
authored
4月 19, 2016
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert NanGuardMode to use the VM linker instead of WrapLinker.
上级
69338f33
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
33 行删除
+10
-33
nanguardmode.py
theano/compile/nanguardmode.py
+10
-33
没有找到文件。
theano/compile/nanguardmode.py
浏览文件 @
49590e13
...
@@ -211,7 +211,7 @@ class NanGuardMode(Mode):
...
@@ -211,7 +211,7 @@ class NanGuardMode(Mode):
assert
nan_is_error
or
inf_is_error
or
big_is_error
assert
nan_is_error
or
inf_is_error
or
big_is_error
compile_gpu_func
(
nan_is_error
,
inf_is_error
,
big_is_error
)
compile_gpu_func
(
nan_is_error
,
inf_is_error
,
big_is_error
)
def
do_check_on
(
var
,
nd
,
f
,
is_input
):
def
do_check_on
(
var
,
nd
):
"""
"""
Checks `var` for NaNs / Infs. If detected, raises an exception
Checks `var` for NaNs / Infs. If detected, raises an exception
and / or prints information about `nd`, `f`, and `is_input` to
and / or prints information about `nd`, `f`, and `is_input` to
...
@@ -223,11 +223,6 @@ class NanGuardMode(Mode):
...
@@ -223,11 +223,6 @@ class NanGuardMode(Mode):
The value to be checked.
The value to be checked.
nd : theano.gof.Apply
nd : theano.gof.Apply
The Apply node being executed.
The Apply node being executed.
f : callable
The thunk for the apply node.
is_input : bool
If True, `var` is an input to `nd`.
If False, it is an output.
"""
"""
error
=
False
error
=
False
...
@@ -256,17 +251,9 @@ class NanGuardMode(Mode):
...
@@ -256,17 +251,9 @@ class NanGuardMode(Mode):
print
(
'Big value detected'
,
file
=
sio
)
print
(
'Big value detected'
,
file
=
sio
)
error
=
True
error
=
True
if
error
:
if
error
:
if
not
is_input
:
print
(
"NanGuardMode found an error in the"
print
(
"NanGuardMode found an error in the"
" output of a node in this variable:"
,
file
=
sio
)
" output of a node in this variable:"
,
file
=
sio
)
print
(
theano
.
printing
.
debugprint
(
nd
,
file
=
'str'
),
file
=
sio
)
print
(
theano
.
printing
.
debugprint
(
nd
,
file
=
'str'
),
file
=
sio
)
else
:
print
(
"NanGuardMode found an error in an"
" input of this node."
,
file
=
sio
)
print
(
'Node:'
,
file
=
sio
)
print
(
nd
,
file
=
sio
)
print
(
"The input variable that cause problem:"
,
file
=
sio
)
print
(
theano
.
printing
.
debugprint
(
nd
,
file
=
'str'
),
file
=
sio
)
msg
=
sio
.
getvalue
()
msg
=
sio
.
getvalue
()
if
config
.
NanGuardMode
.
action
==
'raise'
:
if
config
.
NanGuardMode
.
action
==
'raise'
:
raise
AssertionError
(
msg
)
raise
AssertionError
(
msg
)
...
@@ -277,36 +264,26 @@ class NanGuardMode(Mode):
...
@@ -277,36 +264,26 @@ class NanGuardMode(Mode):
elif
config
.
NanGuardMode
.
action
==
'warn'
:
elif
config
.
NanGuardMode
.
action
==
'warn'
:
logger
.
error
(
msg
)
logger
.
error
(
msg
)
def
nan_check
(
i
,
node
,
fn
):
def
nan_check
(
node
,
thunk
,
storage_map
,
compute_map
):
"""
"""
Runs `fn` while checking its inputs and outputs for NaNs / Infs.
Runs `fn` while checking its inputs and outputs for NaNs / Infs.
Parameters
Parameters
----------
----------
i :
Currently ignored.
TODO: determine why it is here or remove).
node : theano.gof.Apply
node : theano.gof.Apply
The Apply node currently being executed.
The Apply node currently being executed.
fn
: callable
thunk
: callable
The thunk to execute for this Apply node.
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)
"""
"""
inputs
=
fn
.
inputs
for
var
in
node
.
outputs
:
for
x
,
var
in
zip
(
inputs
,
node
.
inputs
):
# If the input is the result of computation, then we
# don't need to check it. It is already done after the
# computation.
if
(
var
.
owner
is
None
and
getattr
(
var
.
tag
,
'nan_guard_mode_check'
,
True
)):
do_check_on
(
x
[
0
],
node
,
fn
,
True
)
fn
()
outputs
=
fn
.
outputs
for
x
,
var
in
zip
(
outputs
,
node
.
outputs
):
if
getattr
(
var
.
tag
,
'nan_guard_mode_check'
,
True
):
if
getattr
(
var
.
tag
,
'nan_guard_mode_check'
,
True
):
do_check_on
(
x
[
0
],
node
,
fn
,
Fals
e
)
do_check_on
(
storage_map
[
var
][
0
],
nod
e
)
wrap_linker
=
theano
.
gof
.
WrapLinker
([
theano
.
gof
.
OpWiseCLinker
()],
wrap_linker
=
theano
.
gof
.
vm
.
VM_Linker
(
callback
=
nan_check
)
nan_check
)
super
(
NanGuardMode
,
self
)
.
__init__
(
wrap_linker
,
super
(
NanGuardMode
,
self
)
.
__init__
(
wrap_linker
,
optimizer
=
self
.
provided_optimizer
)
optimizer
=
self
.
provided_optimizer
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论