我正在使用pokemon kaggle数据集的tflearn。 我试图把口袋妖怪的名字作为word2vec,其余作为普通矩阵。 我正在尝试预处理数据。
我所做的是使用TF学习将名称更改为向量
word_processor = VocabularyProcessor(100)
trainX = newDF.loc[:, ["Total","HP","Attack","Defense","Sp. Atk", "Sp. Def","Speed","Generation"]].as_matrix()
trainY = np.array(list(word_processor.fit_transform(newDF["Name"])))
trainY[None : 0]
print('shape trainX: ',trainX.shape)
print('shape train Y: ',trainY.shape)
打印声明显示
shape trainX: (800, 8)
shape train Y: (800, 100)
所以我认为这是问题所在,因为当我试图将这些数据提供给我的神经网络时,它会显示出来。
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-53-78ce72c15f14> in <module>()
3 # Start training (apply gradient descent algorithm)
4 # Training
----> 5 model.fit(trainX, trainY, validation_set=0.1, show_metric=True, batch_size=100, n_epoch=8)
/anaconda/envs/MLHardCore/lib/python3.5/site-packages/tflearn/models/dnn.py in fit(self, X_inputs, Y_targets, n_epoch, validation_set, show_metric, batch_size, shuffle, snapshot_epoch, snapshot_step, excl_trainops, validation_batch_size, run_id, callbacks)
181 # TODO: check memory impact for large data and multiple optimizers
182 feed_dict = feed_dict_builder(X_inputs, Y_targets, self.inputs,
--> 183 self.targets)
184 feed_dicts = [feed_dict for i in self.train_ops]
185 val_feed_dicts = None
/anaconda/envs/MLHardCore/lib/python3.5/site-packages/tflearn/utils.py in feed_dict_builder(X, Y, net_inputs, net_targets)
281 X = [X]
282 for i, x in enumerate(X):
--> 283 feed_dict[net_inputs[i]] = x
284 else:
285 # If a dict is provided
IndexError: list index out of range
这是神经网络刚刚加入
def NN():
net = tflearn.input_data(shape=[None, 8])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net)
model = tflearn.DNN(net)
return model
model = NN()
model.fit(trainX, trainY, validation_set=0.1, show_metric=True, batch_size=100, n_epoch=8)
我重新启动python之后的另一个新错误。
Exception in thread Thread-6:
line 187, in slice_array
return X[start]
IndexError: index 359 is out of bounds for axis 0 with size 100
答案 0 :(得分:0)
尝试重新启动内核并清除输出并再次运行。 我也遇到过这个问题,这个解决方案对我有用。