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

Python 无法使用张量流打印正确的预测,python,tensorflow,softmax,Python,Tensorflow,Softmax,我已经实现了一个逻辑回归,效果很好。它正确地打印出准确度。我显示的准确性,以便 # 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: mnis

我已经实现了一个逻辑回归,效果很好。它正确地打印出准确度。我显示的准确性,以便

# 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}))
正如我所说,这很好用。然而,在阅读了一篇教程之后,我知道
正确的预测应该是一组布尔值,告诉我们我们的预测是否正确。我想打印这个布尔值,但遇到了问题。我尝试了以下方法

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}))