尝试对字段'icgnn'进行索引,但值为nil

以下是我正在使用的代码:

local IcgResample, Parent = torch.class('icgnn.IcgResample', 'nn.Module')

function IcgResample:__init(inter_method, height_factor, width_factor, antialiasing)
  Parent.__init(self)

  if inter_method then
    self.inter_method = inter_method
  else
    error('您必须指定一种插值方法')
  end

  self.height_factor = height_factor or 2
  self.width_factor = width_factor or height_factor

  if self.height_factor <= 0 or self.width_factor <= 0 then
    error('因素必须大于0')
  end

  if antialiasing then
    self.antialiasing = true
  else
    self.antialiasing = false
  end
end

function IcgResample:updateOutput(input)
  input.icgnn.IcgResample_updateOutput(self, input)
  return self.output
end

function IcgResample:updateGradInput(input, gradOutput)
  input.icgnn.IcgResample_updateGradInput(self, input, gradOutput)
  return self.gradInput
end

我遇到了题目所说的错误。我是lua的新手,我要赶快运行这个代码,请问有谁知道如何解决这个问题吗?我已经打印了输入数据,它是一个cudaTensor。icgnn是一个模块。

点赞
用户369792
用户369792

问题是输入没有 icgnn 字段。这个错误告诉您正在尝试 somevariable.icgnn.someproperty,但 somevariable.icgnn 为空。'indexing' 是指尝试访问命名字段上的属性:codepad sample

local variable = {}
variable.exists = {}
print(variable.exists.message) -- fine
print(variable.icgnn.message)  -- error, trying to index field icgnn that is nil
2018-07-23 17:40:03