我在自己的数据集中使用Tensor Flow的retraining示例。最终的测试评估输出最终的测试精度和错误分类图像的名称:
test_accuracy, predictions = eval_session.run(
[evaluation_step, prediction],
feed_dict={
bottleneck_input: test_bottlenecks,
ground_truth_input: test_ground_truth
})
tf.logging.info('Final test accuracy = %.1f%% (N=%d)' %
(test_accuracy * 100, len(test_bottlenecks)))
if FLAGS.print_misclassified_test_images:
tf.logging.info('=== MISCLASSIFIED TEST IMAGES ===')
for i, test_filename in enumerate(test_filenames):
if predictions[i] != test_ground_truth[i]:
tf.logging.info('%70s %s' % (test_filename, list(image_lists.keys())[predictions[i]]))
如何打印与所有类的预测相关的概率?
例如:
image1 - A:0.5; B:0.3; C:0.1; D:0.1
image2 - A:0.3; B:0.2; C:0:4; D:0.1
答案 0 :(得分:0)
我想我自己找到了答案。
概率可以这样获得:
probs = tf.nn.softmax(final_tensor)
probabilities = sess.run(probs, feed_dict={bottleneck_input: test_bottlenecks,
ground_truth_input: test_ground_truth})
然后,可以像这样访问它们:
for i, test_filename in enumerate(test_filenames):
tf.logging.info('%70s %f %f %f %f' %
(test_filename,
probabilities[i][0], probabilities[i][1], probabilities[i][2], probabilities[i][3]))