lua:第二个参数#2的错误(起始索引超出范围)

输入图像描述

最近我使用torch7运行模型,但这个错误经常出现,让我疯狂。

谁能帮帮我?

点赞
用户10018042
用户10018042

我对 torch7 不熟悉,但我会引导你到这个帖子,似乎是相同或相似的问题,由数据集过小造成。

https://github.com/jcjohnson/torch-rnn/issues/201

2018-07-02 16:17:52
用户2696875
用户2696875

当使用以下代码行时出现错误:

self.val_left[i] = self.ldata[img_id][{{}, {center_y-self.psz, center_y+self.psz}, {center_x-self.psz, center_x+self.psz}}]

堆栈跟踪告诉我们,在Tensor.c中的一个函数中有一个失败的参数检查:

static int torch_Tensor_(__index__)(lua_State *L)
{
  ...
  for(dim = 0; dim < ndims; dim++)
  {
    ...
    else if(lua_istable(L, 2))
    {
      ...
      THArgCheck((start >= 0) && (start < tensor->size[cdim]), 2, "start index out of bound");
      ...
    }
  ...
  }
}

这是使用表参数进行缩小和选择的索引运算符的实现。似乎,其中一个维度中计算出的第一个索引过大还是过小。

尝试打印center_y-self.pszcenter_x-self.psz的值,以查看哪个是罪魁祸首,并在哪个端点超出了限制。我无法给出更多建议,因为我不熟悉其余的代码或数据。

2018-07-03 06:57:47