无法使用张量流打印正确的预测

Cannot print correct predictions using tensor flow

我实施了一个运行良好的逻辑回归。它正确地打印出准确度。我这样显示准确度...

# Test model
correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
# Calculate accuracy
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

print("Accuracy:", accuracy.eval({x: mnist.test.images, y: mnist.test.labels}))

正如我所说,这很好用。然而,在阅读教程后,我知道 correct_prediction 应该是一个布尔数组,告诉我们我们的预测是否正确。我想打印这个布尔值,但我 运行 遇到了问题。我尝试了以下...

print(correct_prediction)
>>>Tensor("Equal:0", shape=(?,), dtype=bool)

然后我尝试了...

print(sess.run(correct_prediction))
>>>InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype float
 [[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

我对 TensorFlow 很陌生。如何将此变量作为预测数组打印出来?

您还需要输入数据。尝试:

print(correct_prediction.eval({x: mnist.test.images, y: mnist.test.labels}))