我认为您只需要按照教程中所述评估输出张量即可:
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))要获取张量的输出,请参阅docs:
在会话中启动图后,可以将Tensor的值传递给Session.run()来计算它的值。t.eval()是调用tf.get_default_session()。run(t)的快捷方式。
如果要获得预测而不是准确性,则需要以
y相同的方式评估输出张量:
print(sess.run(y, feed_dict={x: mnist.test.images}))


