Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
351bdd7e
提交
351bdd7e
authored
7月 02, 2015
作者:
hantek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add docs for NanGuardMode
上级
f641f02e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
64 行增加
和
8 行删除
+64
-8
nanguardmode.txt
doc/library/compile/nanguardmode.txt
+52
-1
nan_tutorial.txt
doc/tutorial/nan_tutorial.txt
+12
-7
没有找到文件。
doc/library/compile/nanguardmode.txt
浏览文件 @
351bdd7e
...
@@ -16,4 +16,55 @@ Guide
...
@@ -16,4 +16,55 @@ Guide
The NanGuardMode aims to prevent the model from outputing NaNs or Infs. It has
The NanGuardMode aims to prevent the model from outputing NaNs or Infs. It has
a number of self-checks, which can help to find out which apply node is
a number of self-checks, which can help to find out which apply node is
generating those incorrect outputs.
generating those incorrect outputs. It provides automatic detection on 3 types
of abnormal values: NaNs, Infs, and abnormally big values.
NanGuardMode can be used as follows:
.. code-block:: python
x = T.matrix()
w = theano.shared(numpy.random.randn(5, 7).astype(theano.config.floatX))
y = T.dot(x, w)
fun = theano.function(
[x], y,
mode=NanGuardMode(nan_is_error=True, inf_is_error=True, big_is_error=True)
)
While using the theano function ``fun``, it will monitor the values of each
input and output variable of each node. As long as the abnormal values are
detected, it raises an error to indicate which node yields the NaNs. For
example, if we pass the following values to ``fun``:
.. code-block:: python
infa = numpy.tile(
(numpy.asarray(100.) ** 1000000).astype(theano.config.floatX), (3, 5))
fun(infa)
It will raise an AssertionError indicating that Inf value is detected while
executing the function.
You can also set the three parameters in ``NanGuardMode()`` to indicate which
kind of abnormal values to monitor. ``nan_is_error`` and ``inf_is_error`` has
no default values, so they need to be set explicitly, but ``big_is_error`` is
set to be ``True`` by default.
Reference
=========
.. class:: NanGuardMode(Mode)
A Theano compilation Mode that makes the compiled function automatically
detect NaNs and Infs and raise an error if they occur.
Parameters
----------
nan_is_error : bool
If True, raise an error anytime a NaN is encountered
inf_is_error: bool
If True, raise an error anytime an Inf is encountered. Note that some
modules might use np.inf as a default value (e.g. mlp.max_pool in
pylearn2) and these will cause an error if inf_is_error is True.
big_is_error: bool
If True, raise an error when a value greater than 1e10 is encountered.
doc/tutorial/nan_tutorial.txt
浏览文件 @
351bdd7e
...
@@ -33,19 +33,24 @@ those weights are not initialized in a proper range, then it is not surprising
...
@@ -33,19 +33,24 @@ those weights are not initialized in a proper range, then it is not surprising
that the model ends up with yielding NaNs.
that the model ends up with yielding NaNs.
Run in
Debug
Mode
Run in
NanGuardMode, DebugMode, or Monitor
Mode
-----------------
-----------------
------------------------------
If adjusting hyperparameters doesn't work for you, you can still get help from
If adjusting hyperparameters doesn't work for you, you can still get help from
Theano's DebugMode. Run your code in DebugMode with flag mode=DebugMode,
Theano's NanGuardMode. change the mode of your theano function to NanGuardMode,
and run them again. The NanGuardMode will monitor all input/output variables in
each node, and raises an error if NaNs are detected. For how to use the
``NanGuardMode``, please refer to :ref:`nanguardmode`.
DebugMode can also help. Run your code in DebugMode with flag mode=DebugMode,
DebugMode.check_py=False. This will give you clue about which op is causing this
DebugMode.check_py=False. This will give you clue about which op is causing this
problem, and then you can inspect into that op in more detail. For a detailed
problem, and then you can inspect into that op in more detail. For a detailed
of using DebugMode, please refere to :ref:`debugmode`.
of using DebugMode, please refere to :ref:`debugmode`.
Theano's MonitorMode
can also help. It can be used to step through the execution
Theano's MonitorMode
provides another helping hand. It can be used to step
of a function. You can inspect the inputs and outputs of each node being
through the execution of a function. You can inspect the inputs and outputs of
e
xecuted when the function is called. For how to use that, please check
e
ach node being executed when the function is called. For how to use that,
:ref:`faq_monitormode`.
please check :ref:`faq_monitormode`.
Numerical Stability
Numerical Stability
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论