我的theano程序中有一个错误导致了NaN值。doc建议使用nanguardmode
来追踪问题的根源。在
当我从doc网页复制/粘贴这一行时:
from theano.compile.nanguardmode import NanGuardMode
我得到:
^{pr2}$键入以下内容时找不到nanguardmode
的任何符号:
help(theano.compile)
你知道为什么nanguardmode
缺席吗?我该怎么解决这个问题?在
编辑:
谢谢你的回复。在
关于我的Theano版本,我找不到如何检查它。但我认为它是最新的:我大约一个月前从安装网页安装的。64M位。在
关于detect\u nan hack:事情变得更奇怪了!在
第一:如果我尝试使用:
post_func=theano.compile.monitormode.detect_nan
我得到:
File "C:\SciSoft\WinPython-64bit-2.7.9.4\python-2.7.10.amd64\lib\site-packages\theano\compile\monitormode.py", line 87, in detect_nan
if (not isinstance(numpy.random.RandomState, output[0]) and
NameError: global name 'numpy' is not defined
事实上,numpy不是在monitormode模块中导入的。。。那是已知的窃听器吗?在
第二:如果我尝试使用detect_ngnan的复制/粘贴,nan会神奇地消失。其他一切都保持不变,在我的theano函数中没有detect iu nan(迭代训练模型),我在迭代5得到nan:
epoch 1, valid 28.582677 %, train 27.723320 % 0.546633
epoch 2, valid 27.814961 %, train 25.681751 % 0.500522
epoch 3, valid 27.263780 %, train 24.262972 % 0.478799
epoch 4, valid 26.938976 %, train 23.209021 % 0.463017
epoch 5, valid 50.000000 %, train 50.000000 % nan
(最后一个数字是成本价值)
当我添加
mode=theano.compile.MonitorMode(post_func=detect_nan)
对于函数,至少在迭代100次(甚至更多)之前没有出现任何nan。在
epoch 1, valid 28.582677 %, train 27.723320 % 0.546633
epoch 2, valid 27.814961 %, train 25.681751 % 0.500522
epoch 3, valid 27.263780 %, train 24.262972 % 0.478799
epoch 4, valid 26.938976 %, train 23.209021 % 0.463017
epoch 5, valid 26.289370 %, train 22.320902 % 0.450454
... etc ...
这是怎么回事???在
NanGuardMode
于5月1日被移到Theano的最新版本(来自PyLearn2),这是在3月26日版本0.7发布之后,因此您需要从GitHub中upgrade to the bleeding edge version来使用NanGuardMode。在或者,您可以使用debug FAQ中的
detect_nan
示例:相关问题 更多 >
编程相关推荐