Tensorflow:教程中的占位符大小问题

Tensorflow: Placeholder Size Issue in Tutorial

我正在关注 Tensorflow's Deep MNIST tutorial。当我运行下面一行

train_step.run(feed_dict={x: batch[0], y_: batch[1]})

我收到以下错误

ValueError: Cannot feed value of shape (50, 784) for Tensor 'Placeholder:0', which has shape '(?, 748)'

它似乎对我的喂养方式不满意x。我将 x 设置为以下占位符:

x = tf.placeholder(tf.float32, shape=[None, 748]) 

我检查过 batch[0] 是一个大小为 50x748 的 float32 numpy 数组。将数组提供给 x 的正确方法是什么?

这只是您的占位符中的错字,请注意

Cannot feed value of shape (50, 784) for Tensor 'Placeholder:0', which has shape '(?, 748)'

Feed 中的形状为 784,而占位符为 748,因此您只需将占位符更改为

x = tf.placeholder(tf.float32, shape=[None, 784]) 

也别担心每个人都会遇到这种情况:)