Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
788061af
提交
788061af
authored
2月 15, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the refactoring to keep the difference between the data and the symbolic variable.
上级
0f374035
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
10 行删除
+11
-10
nanguardmode.py
theano/compile/nanguardmode.py
+11
-10
没有找到文件。
theano/compile/nanguardmode.py
浏览文件 @
788061af
...
@@ -23,14 +23,15 @@ except ImportError:
...
@@ -23,14 +23,15 @@ except ImportError:
logger
=
logging
.
getLogger
(
"theano.compile.nanguardmode"
)
logger
=
logging
.
getLogger
(
"theano.compile.nanguardmode"
)
def
_non_numeric_value
(
var
):
def
_non_numeric_value
(
arr
,
var
):
"""
"""
Checks a variable against non-numeric types such as types, slices,
Checks a variable against non-numeric types such as types, slices,
empty arrays, and None, that need not be checked for NaN and Inf values.
empty arrays, and None, that need not be checked for NaN and Inf values.
Parameters
Parameters
----------
----------
var : output of any Theano op.
arr : the data of that correspond to any Theano Variable
var : The corresponding Theano variable
Returns
Returns
-------
-------
...
@@ -38,17 +39,17 @@ def _non_numeric_value(var):
...
@@ -38,17 +39,17 @@ def _non_numeric_value(var):
`True` the value is non-numeric.
`True` the value is non-numeric.
"""
"""
if
isinstance
(
var
,
theano
.
gof
.
type
.
CDataT
ype
.
_cdata_type
):
if
isinstance
(
arr
,
theano
.
gof
.
t
ype
.
_cdata_type
):
return
True
return
True
elif
isinstance
(
va
r
,
np
.
random
.
mtrand
.
RandomState
):
elif
isinstance
(
ar
r
,
np
.
random
.
mtrand
.
RandomState
):
return
True
return
True
elif
var
and
getattr
(
var
.
tag
,
'is_rng'
,
False
):
elif
var
and
getattr
(
var
.
tag
,
'is_rng'
,
False
):
return
False
return
False
elif
isinstance
(
va
r
,
slice
):
elif
isinstance
(
ar
r
,
slice
):
return
True
return
True
elif
va
r
is
None
:
elif
ar
r
is
None
:
return
True
return
True
elif
va
r
.
size
==
0
:
elif
ar
r
.
size
==
0
:
return
True
return
True
return
False
return
False
...
@@ -104,7 +105,7 @@ def contains_nan(arr, node=None, var=None):
...
@@ -104,7 +105,7 @@ def contains_nan(arr, node=None, var=None):
construction of a boolean array with the same shape as the input array.
construction of a boolean array with the same shape as the input array.
"""
"""
if
_non_numeric_value
(
arr
):
if
_non_numeric_value
(
arr
,
var
):
return
False
return
False
elif
cuda
.
cuda_available
and
isinstance
(
arr
,
cuda
.
CudaNdarray
):
elif
cuda
.
cuda_available
and
isinstance
(
arr
,
cuda
.
CudaNdarray
):
if
(
node
and
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
if
(
node
and
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
...
@@ -147,7 +148,7 @@ def contains_inf(arr, node=None, var=None):
...
@@ -147,7 +148,7 @@ def contains_inf(arr, node=None, var=None):
boolean array with the same shape as the input array.
boolean array with the same shape as the input array.
"""
"""
if
_non_numeric_value
(
arr
):
if
_non_numeric_value
(
arr
,
var
):
return
False
return
False
elif
cuda
.
cuda_available
and
isinstance
(
arr
,
cuda
.
CudaNdarray
):
elif
cuda
.
cuda_available
and
isinstance
(
arr
,
cuda
.
CudaNdarray
):
if
(
node
and
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
if
(
node
and
hasattr
(
theano
.
sandbox
,
'rng_mrg'
)
and
...
@@ -301,7 +302,7 @@ class NanGuardMode(Mode):
...
@@ -301,7 +302,7 @@ class NanGuardMode(Mode):
error
=
True
error
=
True
if
big_is_error
:
if
big_is_error
:
err
=
False
err
=
False
if
_non_numeric_value
(
var
):
if
_non_numeric_value
(
va
lue
,
va
r
):
err
=
False
err
=
False
elif
cuda
.
cuda_available
and
isinstance
(
value
,
cuda
.
CudaNdarray
):
elif
cuda
.
cuda_available
and
isinstance
(
value
,
cuda
.
CudaNdarray
):
compile_gpu_func
(
False
,
False
,
True
)
compile_gpu_func
(
False
,
False
,
True
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论