gpt4 book ai didi

python - 功能和标签尺寸崩溃 (tflearn)

转载 作者:行者123 更新时间:2023-11-28 19:08:36 25 4
gpt4 key购买 nike

我正在玩带有 pokemon kaggle 数据集的 tflearn。我试图将宠物小 Sprite 的名称作为 word2vec,其余作为普通矩阵。我正在尝试预处理数据。 enter image description here

我所做的是使用 TF learn 将 Name 更改为 vector

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)

打印语句显示形状 trainX: (800, 8)形状火车 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

最佳答案

尝试重新启动内核并清除输出并再次运行。我也遇到过这个问题,这个解决方案对我有用。

关于python - 功能和标签尺寸崩溃 (tflearn),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43420755/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com