【问题标题】:IndexError: index 149 is out of bounds for axis 0 with size 149IndexError:索引 149 超出轴 0 的范围,大小为 149
【发布时间】:2016-02-23 06:05:25
【问题描述】:

我已经搜索了以下错误,但找不到正确的解决方案。错误发生在以下代码中。

inputs=numpy.zeros((features,128),'f')
offset = 0
for index in range(len(seqTags)):
    d=rawInputs[index]
    w,h=d.shape
    for i in range(90):
            inputs[offset,:]=d[i,:]
            offset+=1

//The varriable i runs 90 times correctly when index= 0.
//When index =1 and i=59 it stuck with this error.
// The seqTags= number of files

错误:

inputs[offset,:]=d[i,:]

IndexError: index 149 is out of bounds for axis 0 with size 149

任何帮助将不胜感激!

【问题讨论】:

标签: python arrays arraylist sift


【解决方案1】:

计算机从 0 开始计数,因此大小为 149 的列表或数组 d 具有成员 d[0]..d[148]

索引149 尝试查看数组中不存在的150th 成员,导致您看到的错误。

【讨论】:

  • 但是 len(d) == 90 并且当 index 为 0 时此代码运行良好。这意味着它执行 i 的所有值(即 90),当 i=59 和 index 时出现问题=1
猜你喜欢
  • 1970-01-01
  • 2017-02-16
  • 2020-04-24
  • 2016-07-29
  • 2021-07-17
  • 2021-05-24
  • 2018-07-23
  • 2019-03-01
  • 2021-08-23
相关资源
最近更新 更多