Lua:使用神经网络的语义相似性 [英] Lua: Semantic Similarity using Neural Networks
问题描述
我是Lua编程的新手,我正在尝试使用神经网络执行语义相似性.我在 https://github.com/hohoCode/textSimilarityConvNet
中获得了代码它有
include('Conv.lua')
modelTrained = torch.load("download_local_location/modelSTS.trained.th", 'ascii')
modelTrained.convModel:evaluate()
modelTrained.softMaxC:evaluate()
local linputs = torch.zeros(rigth_sentence_length, emd_dimension)
linpus = XassignEmbeddingValuesX
local rinputs = torch.zeros(left_sentence_length, emd_dimension)
rinpus = XassignEmbeddingValuesX
local part2 = modelTrained.convModel:forward({linputs, rinputs})
local output = modelTrained.softMaxC:forward(part2)
local val = torch.range(0, 5, 1):dot(output:exp())
return val/5
当我运行显示的代码时
attempt to call global 'include' (a nil value)
但是我将Conv.lua文件放在了相同的位置.有人可以建议我解决这个问题.
您会收到此错误消息,因为textSimilarityConvNet期望有一个可以使用的全局include
函数,但尚未加载该函数. /p>
在Lua中,未定义的值默认为nil
,这就是为什么看到错误的原因.您要让Lua调用include
函数,但是名为include
的变量不是函数,因此无法调用.
include
函数是Torch库的一部分(定义为安装页面,以查看是否错过了任何步骤.
I'm new to Lua programming and I'm trying to execute the semantic similarity using neural network. I get a code in https://github.com/hohoCode/textSimilarityConvNet
And it has,
include('Conv.lua')
modelTrained = torch.load("download_local_location/modelSTS.trained.th", 'ascii')
modelTrained.convModel:evaluate()
modelTrained.softMaxC:evaluate()
local linputs = torch.zeros(rigth_sentence_length, emd_dimension)
linpus = XassignEmbeddingValuesX
local rinputs = torch.zeros(left_sentence_length, emd_dimension)
rinpus = XassignEmbeddingValuesX
local part2 = modelTrained.convModel:forward({linputs, rinputs})
local output = modelTrained.softMaxC:forward(part2)
local val = torch.range(0, 5, 1):dot(output:exp())
return val/5
when I run the code it shows
attempt to call global 'include' (a nil value)
But I've placed the Conv.lua file in same location. Can someone suggest me to solve this.
You're getting this error message because textSimilarityConvNet expects there to be a global include
function that it can use, but that function has not been loaded.
In Lua, values that are not defined default to nil
, which is why you see the error you do. You're asking Lua to call the include
function, but the variable called include
isn't a function, so it can't be called.
The include
function is a part of the Torch library (it is defined here), so the fundamental cause of your problem is probably that Torch isn't installed correctly. Try checking the installation page to see if you have missed any steps.
这篇关于Lua:使用神经网络的语义相似性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!