相似性度量是无效的模块名称 [英] SimilarityMeasure is an invalid module name

查看:143
本文介绍了相似性度量是无效的模块名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我先前的问题 Lua:使用神经网络的语义相似性的后续行动.

This is a follow-up to my earlier question Lua: Semantic Similarity using Neural Networks.

对于语义相似性,我执行以下代码,

For Semantic similarity I've execute the following code,

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

然后在终端中使用以下命令执行

And Execute it using the following command in terminal,

> th similarity.lua

但是显示的错误是

while creating metatable similarityMeasure.Conv: bad argument #1 (similarityMeasure is an invalid module name)
stack traceback:
[C]: in function 'newmetatable'
/torch/install/share/lua/5.2/torch/init.lua:102: in function 'class'
.../textSimilarityConvNet-master/Conv.lua:1: in main chunk
[C]: in function 'dofile'
/torch/install/share/lua/5.2/paths/init.lua:84: in function 'dofile'
/torch/install/share/lua/5.2/torch/init.lua:49: in function 'include'
similarity.lua:1: in main chunk
[C]: in function 'dofile'
.../torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: in ?

Conv.lua的前几行是

First few lines in Conv.lua is,

local Conv = torch.class('similarityMeasure.Conv')

function Conv:__init(config)
  self.mem_dim       = config.mem_dim       or 150
  self.learning_rate = config.learning_rate or 0.01
  self.batch_size    = config.batch_size    or 1 --25
  self.num_layers    = config.num_layers    or 1
  self.reg           = config.reg           or 1e-4
  self.structure     = config.structure     or 'lstm' -- {lstm, bilstm}
  self.sim_nhidden   = config.sim_nhidden   or 150
  self.task          = config.task          or 'sic'  -- or 'vid'

  -- word embedding
  self.emb_vecs = config.emb_vecs
  self.emb_dim = config.emb_vecs:size(2)

请指导我解决这个问题.

Please guide me to solve this.

推荐答案

您缺少了similarityMeasure模块(也可能缺少其他模块).我猜测您缺少的是默认Torch安装中未包含的依赖项. Github存储库的自述文件中的安装说明说:

You are missing the similarityMeasure module (and likely other modules as well). I'm guessing that the things you are missing are dependencies that are not included with the default Torch installation. The installation instructions in the Github respository's readme file say the following:

请安装Torch深度学习库.我们推荐这个本地 安装包括我们工具所需的所有必需软件包, 只需按照以下说明进行操作即可: https://github.com/torch/distro

Please install Torch deep learning library. We recommend this local installation which includes all required packages our tool needs, simply follow the instructions here: https://github.com/torch/distro

如果您以其他方式安装了Torch,请尝试使用链接的发行版进行安装,看看是否可以解决问题.

If you installed Torch some other way, try doing it using the linked distro instead and see if that fixes the problem.

这篇关于相似性度量是无效的模块名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆