我有lua 5.2,Torch版本7,Ubuntu版本14.04可信赖已安装
我正在尝试运行以下代码 ++++++++++++++++++++++代码++++++++++++++++++++++++++++++++++++++++++++
require 'neuralconvo' require 'xlua'
-- Load Dataset
print("--Loading Dataset")
dataset=neuralconvo.Dataset(neuralconvo.CornellMovieDiaogs("data/cornell_movie_diaogs"),
{ loadFirst = options.dataset,
minWordFreq = options.minWordFreq
})
--Build Model
model = neuralconvo.Seq2Seq(dataset.wordsCount, options.hiddenSize) model.goToken = dataset.goToken
model.eosToken=dataset.eosToken
--Training Parameters
model.criterion=nn.SequencerCriterion(nn.ClassNLLCriterion())
model.learningRaw = options.learningRate
model.momentum = otions.momentum
local decayFactor = (options.minLR - options.learningRate)/options.saturateEpoch local minMeanError = nil
--Enable Cuda
if options.cuda then
require 'cutorch'
require 'cunn'
elseif options.opencl then
require 'cltorch'
require 'clnn'
model:cl()
end
-- Train Model using backpropogation
for epoch = 1,options.maxEpoch do
local errors = torch.Tensor(dataset.examplesCount):fill(0)
local timer=torch.timer()
local i=1
for examples in dataset:batches(options.batchSize) do
collectgarbage()
for _, example in ipairs(examples) do
local input, target = unpack(examples) do
if options.cuda then
input = input:cuda()
target = target:cuda()
elseif options.opencl then
input = input:cl()
target = target:cl()
end
local err=model:train(input, target)
if err ~= err then
error("Invalid error! Exiting.")
end
errors[i] = err
xlua.progress(i, dataset.examplesCount)
i=i+1
end
end
timer:stop()
--Save the model if not Improved
if minMeanError == nil or errors:mean() < minMeanError then
print("\n(Saving model...)")
torch.save("data/model.t7",model)
minMeanError=errors:mean()
end
-- Update Learning Rate
model.learningRate = model.learningRate + decayFactor
model.learningRate = math.max(options.minLR,model.learningRate)
end
end
=============================================================
我收到以下错误
luajit: error loading module 'libpaths' from file '/home/guru99u2/torch/install/lib/lua/5.2/libpaths.so': /home/guru99u2/torch/install/lib/lua/5.2/libpaths.so: undefined symbol: luaL_setfuncs stack traceback: [C]: at 0x00450240 [C]: in function 'require' /home/guru99u2/torch/install/share/lua/5.2/paths/init.lua:1: in main chunk [C]: in function 'require' /home/guru99u2/torch/install/share/lua/5.2/torch/init.lua:12: in main chunk [C]: in function 'require' ./neuralconvo.lua:1: in main chunk [C]: in function 'require' bot.lua:1: in main chunk [C]: at 0x00404d60
答案 0 :(得分:2)
在安装过程中出现问题(或者您没有清除以前的版本),因为您尝试使用为Lua 5.2构建的模块和支持Lua 5.1 ABI的解释器(在本例中为LuaJIT)。结果你得到了错误undefined symbol: luaL_setfuncs
,因为动态库希望有这个函数,但加载的解释器不提供它。
Torch支持LuaJIT和Lua 5.2,但是当切换Lua版本时,您需要按照documentation中的说明运行./clean.sh
脚本。