最近在用lua torch框架做实验,发现这个框架国内相关的资料不多。实验中使用到rnn框架,输入如下:
require 'rnn'
因为rnn模块不包含于torch的默认安装模块,报错信息如下:
no field package.preload['rnn']
no file '~/.luarocks/share/lua/5.1/rnn.lua'
no file '~/.luarocks/share/lua/5.1/rnn/init.lua'
no file '~/torch/install/share/lua/5.1/rnn.lua'
no file '~/torch/install/share/lua/5.1/rnn/init.lua'
no file './rnn.lua'
no file '~/torch/install/share/luajit-2.1.0-beta1/rnn.lua'
no file '~/share/lua/5.1/rnn.lua'
no file '~/share/lua/5.1/rnn/init.lua'
no file '~/app/.luarocks/share/lua/5.1/rnn.lua'
no file '~/app/.luarocks/share/lua/5.1/rnn/init.lua'
no file '~/.luarocks/lib/lua/5.1/rnn.so'
no file '~/torch/install/lib/lua/5.1/rnn.so'
no file '~/torch/install/lib/rnn.so'
no file './rnn.so'
no file '~/lib/lua/5.1/rnn.so'
no file '~/lib/lua/5.1/loadall.so'
no file '~/app/.luarocks/lib/lua/5.1/rnn.so'
在外网找到两个解法如下:
1. 下载开源rnn模块包,手动编译安装(亲测有效)
git clone https://github.com/Element-Research/rnn.git
cd rnn
luarocks make rocks/rnn-scm-1.rockspec
原答案链接:rnn模块编译
2. 解法二
luarocks install https://raw.githubusercontent.com/jcjohnson/torch-rnn/master/torch-rnn-scm-1.rockspec
cd ~/torch ./clean.sh TORCH_LUA_VERSION=LUA52 ./install.sh
上面两个步骤试了,可能仍然无法成功找到rnn模块,方案出处作者提供了新的安装源,如下。
luarocks install https://raw.githubusercontent.com/qassemoquab/stnbhwd/master/stnbhwd-scm-1.rockspec luarocks install https://raw.githubusercontent.com/jcjohnson/torch-rnn/master/torch-rnn-scm-1.rockspec
欢迎大家多多讨论。