测试Theano_LSTM的Tutorial例子

“A Nonsensical Language Model using Theano LSTM”和 “不可思议的递归神经网络”所实现的例子非常相似。这个NBNotebook其实也是Github上的项目Theano_LSTM中的说明文件。先测试一下上面列出的例子是否能够运行。

1 启动ipython的nbviewer

nbviewer是很炫的功能,但是以前很少用到。我比较喜欢黑色的commandline。

  1. ipython notebook --pylab inline启动nbviewer,在默认的浏览器就能看到新的一个页面。

  2. 从Github下载Theano_lstm代码,解压以后,有个Tutorial.ipynb,就是作者写的Tutorial文件,比readme.md稍微详细一点。

  3. Tutorial.ipynb所在目录下,ipython notebook tutorial.ipynb。发现错误,Json格式不对。Tutorial.ipynb是Json4版本的,我的ipython只能支持到Json3。

  4. 检查我的ipython版本:ipython --version,居然是1.0.0

  5. 下载Anaconda2.2.0版本,安装好以后,ipython --version,升级为3.0.0
  6. ipython notebook tutorial.ipynb,终于可以运行了。
  7. 重新安装theano,参考文章:在Windows 7 (64)上安装Theano
  8. 安装theano_lstm: pip install theano_lstm

2 运行代码

Tutorial.ipynb中的代码合并起来,形成test_lstm.py

python test_lstm.py

得到结果:

epoch 0, error=3468.54
the joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke joke joke joke joke joke joke joke j
oke joke joke joke joke joke joke joke joke
epoch 100, error=2108.66
epoch 200, error=1927.65
epoch 300, error=1769.03
epoch 400, error=1633.89
epoch 500, error=1543.26
the cat cooly ran , from car cooly ran , from joke catapult .
epoch 600, error=1475.61
epoch 700, error=1417.41
epoch 800, error=1372.92
epoch 900, error=1333.32
epoch 1000, error=1306.30
the wrangler do , it dog could book .
epoch 1100, error=1291.08
epoch 1200, error=1245.23
epoch 1300, error=1237.58
epoch 1400, error=1208.10
epoch 1500, error=1181.93
the wrangler do , a broom carried .
epoch 1600, error=1166.97
epoch 1700, error=1147.91
epoch 1800, error=1136.50
epoch 1900, error=1120.01
epoch 2000, error=1101.10
the calendar angrily ran .
epoch 2100, error=1086.28
epoch 2200, error=1078.11

3 问题

Theano compile training function的时候,有错误(但似乎不影响运行):

File "C:\Anaconda\lib\site-packages\theano\tensor\basic.py", line 1252, in mak
e_node
    raise TypeError("MaxAndArgmax needs a constant axis")
TypeError: MaxAndArgmax needs a constant axis

原因好像是:

It looks like the “axis” variable that is an input to an existing “_max_and_argmax” operator is not a Constant .

还需要仔细深入研究一下。

你可能感兴趣的:(deep-learning)