IndexError:索引686超出了轴0大小为400的边界



但是,当我想用收集到的数据训练模型时,IndexError会不断弹出。我试过使用不同的模型或重建模型。不确定这是否是一个numpy数组错误,但我很确定这是与一些东西,当我做模型。fit()。

当前的培训和验证分离为训练样本:1200个验证样本:300

如果有帮助的话

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

每次运行时索引错误是不同的

IndexError: index 1157 is out of bounds for axis 0 with size 400
IndexError: index 486 is out of bounds for axis 0 with size 400

完全错误

Exception in thread Thread-8:
Traceback (most recent call last):
self._target(*self._args, **self._kwargs)
File "E:Program Files (x86)Microsoft Visual StudioSharedPython37_64libsite-packagestflearndata_flow.py", line 187, in fill_feed_dict_queue
data = self.retrieve_data(batch_ids)
File "E:Program Files (x86)Microsoft Visual StudioSharedPython37_64libsite-packagestflearndata_flow.py", line 222, in retrieve_data
utils.slice_array(self.feed_dict[key], batch_ids)
File "E:Program Files (x86)Microsoft Visual StudioSharedPython37_64libsite-packagestflearnutils.py", line 204, in slice_array
return X[start]
IndexError: index 486 is out of bounds for axis 0 with size 400
Training samples: 1200
Validation samples: 300
代码:

# train_model.py
import numpy as np
from models import alexnet
WIDTH = 160
HEIGHT = 120
LR = 1e-3
EPOCHS = 10
MODEL_NAME = 'F1-{}-{}-{}.model'.format(LR, 'alexnet',EPOCHS)
model = alexnet(WIDTH, HEIGHT, LR)
hm_data = 22
for i in range(EPOCHS):
for i in range(1,hm_data):
train_data = np.load('D:/Honors/F1/trainingData/training_data-{}.npy'.format(i), allow_pickle=True)
train = train_data[:-100]
test = train_data[-100:]

X = np.array([i[0] for i in train]).reshape(-1,WIDTH,HEIGHT,1)
Y = [i[1] for i in train]
test_x = np.array([i[0] for i in test]).reshape(-1,WIDTH,HEIGHT,1)
test_y = [i[1] for i in test]
model.fit({'input': X}, {'targets': Y}, n_epoch=1, validation_set=({'input': test_x}, {'targets': test_y}), 
snapshot_step=500, show_metric=True, run_id=MODEL_NAME)

model.save(MODEL_NAME)

# tensorboard --logdir=foo:C:/path/to/log



我不能重新运行代码,因为我不知道models是什么。我有一般的建议:使用与外部循环相同索引的内循环不是一个好主意:

for i in range(EPOCHS):
for i in range(1,hm_data):
...

相关内容

  • 没有找到相关文章

最新更新