gpt4 book ai didi

tensorflow - TFLearn 无法正确加载具有形状的训练数据

转载 作者:行者123 更新时间:2023-11-30 09:43:22 25 4
gpt4 key购买 nike

我正在尝试使用 TensorFlow 和 TFLearn 创建一个 AI 来预测 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 尺寸为 (some_length, 36),它不适合尺寸为 (10, 0) 的输入图层。我怀疑你的第二个维度等于 0,形状至少应该为 1。要解决这个问题,你应该这样做:

net = tflearn.input_data(shape=[None, 36])

None 对于动态维度,它将与所有 BATCHSIZE 匹配,无论是 128、1000 还是 2000

关于tensorflow - TFLearn 无法正确加载具有形状的训练数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56080212/

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