【问题标题】:How to print the prediction probabilities in Tensor Flow's retraining example?如何在 Tensor Flow 的再训练示例中打印预测概率?
【发布时间】:2018-06-01 08:31:18
【问题描述】:

我在自己的数据集上使用 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;乙:0.3; C:0.1; D:0.1

image2 - A:0.3;乙:0.2; C: 0:4; D:0.1

【问题讨论】:

    标签: tensorflow pre-trained-model


    【解决方案1】:

    我想我自己找到了答案。

    概率可以这样获得:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-07
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-16
      • 1970-01-01
      • 2018-02-15
      相关资源
      最近更新 更多