Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1077f41d
提交
1077f41d
authored
8月 14, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/compile/nanguardmode.py
上级
a61580dc
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
11 行删除
+22
-11
nanguardmode.py
theano/compile/nanguardmode.py
+22
-11
没有找到文件。
theano/compile/nanguardmode.py
浏览文件 @
1077f41d
...
@@ -16,11 +16,14 @@ def flatten(l):
...
@@ -16,11 +16,14 @@ def flatten(l):
Parameters
Parameters
----------
----------
l : List/tuple/other objects, might be nested.
l : list/tuple/other objects
Might be nested.
Returns
Returns
-------
-------
A flattened list of objects
object
A flattened list of objects.
"""
"""
if
isinstance
(
l
,
(
list
,
tuple
,
collections
.
ValuesView
)):
if
isinstance
(
l
,
(
list
,
tuple
,
collections
.
ValuesView
)):
rval
=
[]
rval
=
[]
...
@@ -53,6 +56,7 @@ def contains_nan(arr):
...
@@ -53,6 +56,7 @@ def contains_nan(arr):
This approach is faster and more memory efficient than the obvious
This approach is faster and more memory efficient than the obvious
alternative, calling `np.any(np.isnan(ndarray))`, which requires the
alternative, calling `np.any(np.isnan(ndarray))`, which requires the
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
isinstance
(
arr
,
theano
.
gof
.
type
.
CDataType
.
_cdata_type
):
if
isinstance
(
arr
,
theano
.
gof
.
type
.
CDataType
.
_cdata_type
):
return
False
return
False
...
@@ -81,6 +85,7 @@ def contains_inf(arr):
...
@@ -81,6 +85,7 @@ def contains_inf(arr):
This approach is more memory efficient than the obvious alternative,
This approach is more memory efficient than the obvious alternative,
calling `np.any(np.isinf(ndarray))`, which requires the construction of a
calling `np.any(np.isinf(ndarray))`, which requires the construction of a
boolean array with the same shape as the input array.
boolean array with the same shape as the input array.
"""
"""
if
isinstance
(
arr
,
theano
.
gof
.
type
.
CDataType
.
_cdata_type
):
if
isinstance
(
arr
,
theano
.
gof
.
type
.
CDataType
.
_cdata_type
):
return
False
return
False
...
@@ -97,14 +102,16 @@ class NanGuardMode(Mode):
...
@@ -97,14 +102,16 @@ class NanGuardMode(Mode):
Parameters
Parameters
----------
----------
nan_is_error : bool
nan_is_error : bool
If True, raise an error anytime a NaN is encountered
If True, raise an error anytime a NaN is encountered
.
inf_is_error: bool
inf_is_error
: bool
If True, raise an error anytime an Inf is encountered. Note that some
If True, raise an error anytime an Inf is encountered. Note that some
pylearn2 modules currently use np.inf as a default value (e.g.
pylearn2 modules currently use np.inf as a default value (e.g.
mlp.max_pool) and these will cause an error if inf_is_error is True.
mlp.max_pool) and these will cause an error if inf_is_error is True.
big_is_error: bool
big_is_error
: bool
If True, raise an error when a value greater than 1e10 is encountered.
If True, raise an error when a value greater than 1e10 is encountered.
"""
"""
def
__init__
(
self
,
nan_is_error
,
inf_is_error
,
big_is_error
=
True
):
def
__init__
(
self
,
nan_is_error
,
inf_is_error
,
big_is_error
=
True
):
if
cuda
.
cuda_available
:
if
cuda
.
cuda_available
:
self
.
guard_input
=
cuda
.
fvector
(
'nan_guard'
)
self
.
guard_input
=
cuda
.
fvector
(
'nan_guard'
)
...
@@ -135,12 +142,13 @@ class NanGuardMode(Mode):
...
@@ -135,12 +142,13 @@ class NanGuardMode(Mode):
var : numpy.ndarray
var : numpy.ndarray
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
f : callable
The thunk for the apply node
The thunk for the apply node
.
is_input : bool
is_input : bool
If True, `var` is an input to `nd`.
If True, `var` is an input to `nd`.
If False, it is an output.
If False, it is an output.
"""
"""
error
=
False
error
=
False
if
nan_is_error
:
if
nan_is_error
:
...
@@ -193,15 +201,18 @@ class NanGuardMode(Mode):
...
@@ -193,15 +201,18 @@ class NanGuardMode(Mode):
def
nan_check
(
i
,
node
,
fn
):
def
nan_check
(
i
,
node
,
fn
):
"""
"""
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)
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
fn : callable
The thunk to execute for this Apply node
The thunk to execute for this Apply node.
"""
"""
inputs
=
fn
.
inputs
inputs
=
fn
.
inputs
# TODO: figure out why individual inputs are themselves lists
# TODO: figure out why individual inputs are themselves lists
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论