Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5a7d9fa4
提交
5a7d9fa4
authored
4月 30, 2015
作者:
hantek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tutorial about NaNs
上级
2907f95a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
84 行增加
和
0 行删除
+84
-0
nanguardmode.txt
doc/library/compile/nanguardmode.txt
+19
-0
nan_tutorial.txt
doc/tutorial/nan_tutorial.txt
+65
-0
没有找到文件。
doc/library/compile/nanguardmode.txt
0 → 100644
浏览文件 @
5a7d9fa4
.. _nanguardmode:
=================
:mod:`nanguardmode`
=================
.. module:: nanguardmode
:platform: Unix, Windows
:synopsis: defines NanGuardMode
.. moduleauthor:: LISA
Guide
=====
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
generating those incorrect output.
doc/tutorial/nan_tutorial.txt
0 → 100644
浏览文件 @
5a7d9fa4
.. _nan_tutorial:
=================
Dealing with NaNs
=================
Having a model yielding NaNs or Infs is quite common if some of the tiny
components in your model are not set correctly. NaNs are hard to deal with
because sometimes it is caused by a bug or error in the code, sometimes it's
because of the numerical stability of your actual computing systerm, and even,
sometimes it relates to your algorithm. Here we try to outline common, basic
issues which cause the model to yield NaNs, as well as provide nails and
hammers to diagnose it.
Check Superparameters and Weight Initialization
-----------------------------------------------
Most frequently, the cause would be that some of the superparameters, especially
learning rates, are set incorrectly. A high learning rate can blow up your whole
model into NaN outputs even within one epoch of training. So the first and
easiest way is try to lower it. Keep halving your learning rate until you start
to get resonable output values.
Other superparameters may also play a role. For example, are your training
algorithms involve regularization terms? If so, are their corresponding
penalties set resonably? Search a wider superparameter space with a few (one or
two) training eopchs each to see if the NaNs could disappear.
Some models can be very sensitive to the initialization of weight vectors. If
those weights are not initialized in a proper range, then it is not surprising
that the model ends up with yielding NaNs.
Run in DebugMode
-----------------
If adjusting superparameters doesn't work for you, you can still get help from
Theano's DebugMode. Run your code in DebugMode with flag
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.
Theano's MonitorMode can also help. It can be used to step through the execution
of a function. You can inspect the inputs and outputs of each node being
executed when the function is called. For how to use that, please check
:ref:`faq_monitormode`.
Numerical Stability
-------------------
After you have located the op which causes the problem, it may turn out that the
NaNs yielded by that op are related to numerical issues. For example,
1 / log(p(x) + 1) may result in NaNs for those nodes who have learned to yield
a low probability p(x) for some input x.
Algorithm Related
-----------------
The hardest thing is that, after tracing back through all the former processes,
it turns out that nothing goes wrong. If unfortunately you reaches here, there
is high chance that something is wrong in your algorithm. Go back to the
mathematics and find out if everything is derived correctly.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论