本文介绍了如何在 TensorFlow 的 MNIST 示例中获得预测的类标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是神经网络的新手,并为初学者学习了 MNIST 示例.

I am new to Neural Networks and went through the MNIST example for beginners.

我目前正在尝试在另一个没有测试标签的 Kaggle 数据集上使用这个例子.

I am currently trying to use this example on another dataset from Kaggle that does not have test labels.

如果我在没有相应标签的测试数据集上运行模型,因此无法像 MNIST 示例中那样计算准确度,我希望能够看到预测.是否有可能以某种方式访问​​观察结果及其预测标签并将其打印出来?

If I run the model on the test data set without corresponding labels and therefore unable to compute the accuracy like in the MNIST example, I would like to be able to see the predictions. Is it possible to access observations and their predicted labels somehow and print them out nicely?

推荐答案

我认为你只需要按照教程中的说明评估你的输出张量:

I think you just need to evaluate your output-tensor as stated in the tutorial:

accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))

要获取张量的输出,请参阅文档:

To get the output of a tensor see the docs:

在会话中启动图形后,可以通过将其传递给 Session.run() 来计算张量的值.t.eval() 是调用 tf.get_default_session().run(t).

如果你想得到预测而不是准确性,你需要以同样的方式评估你的输出张量 y:

If you want to get predictions rather than accuracy, you need to evaluate your ouput tensor y in the same way:

print(sess.run(y, feed_dict={x: mnist.test.images}))

这篇关于如何在 TensorFlow 的 MNIST 示例中获得预测的类标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 12:23