Tensorflow TFLearn无法使用形状正确加载训练数据

Tensorflow TFLearn无法使用形状正确加载训练数据,tensorflow,machine-learning,prediction,tflearn,Tensorflow,Machine Learning,Prediction,Tflearn,我正在尝试创建一个AI,使用tensorflow和TFLearn预测FRC比赛的结果 以下是相关的 x = np.load("FRCPrediction/matchData.npz")["x"] y = np.load("FRCPrediction/matchData.npz")["y"] def buildModel(): net = tflearn.input_data([10, 0]) net = tflearn.fully_connected(net, 64)

我正在尝试创建一个AI,使用tensorflow和TFLearn预测FRC比赛的结果

以下是相关的

x = np.load("FRCPrediction/matchData.npz")["x"]
y = np.load("FRCPrediction/matchData.npz")["y"]

def buildModel():
    net = tflearn.input_data([10, 0])
    net = tflearn.fully_connected(net, 64)
    net = tflearn.dropout(net, 0.5)
    net = tflearn.fully_connected(net, 10, activation='softmax')
    net = tflearn.regression(net, optimizer='adam', loss='categorical_crossentropy')

    model = tflearn.DNN(net)
    return model

model = buildModel()

BATCHSIZE = 128

model.fit(x, y, batch_size = BATCHSIZE)
它失败并出现错误:

Training samples: 36024
Validation samples: 0
--
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-ce7cbb8e618a> in <module>()
----> 1 model.fit(x, y, batch_size = BATCHSIZE)

4 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1126                              'which has shape %r' %
   1127                              (np_val.shape, subfeed_t.name,
-> 1128                               str(subfeed_t.get_shape())))
   1129           if not self.graph.is_feedable(subfeed_t):
   1130             raise ValueError('Tensor %s may not be fed.' % subfeed_t)

ValueError: Cannot feed value of shape (128, 36) for Tensor 'InputData/X:0', which has shape '(?, 10, 0)

非常感谢您的帮助。谢谢。

此错误意味着您的X维度有点长,36不能适合输入层的维度为10,0。我怀疑你的第二维度等于0,形状至少应该是1。 要解决此问题,您应该执行以下操作:

net = tflearn.input_data(shape=[None, 36])
对于将与所有BATCHSIZE(无论是128、1000还是2000)匹配的动态维度,无