Tensorflow 如何打印张量流中的预测概率';什么是再培训的例子?
我在自己的数据集上使用了Tensor Flow的示例。最终测试评估输出最终测试精度和误分类图像的名称:Tensorflow 如何打印张量流中的预测概率';什么是再培训的例子?,tensorflow,pre-trained-model,Tensorflow,Pre Trained Model,我在自己的数据集上使用了Tensor Flow的示例。最终测试评估输出最终测试精度和误分类图像的名称: test_accuracy, predictions = eval_session.run( [evaluation_step, prediction], feed_dict={ bottleneck_input: test_bottlenecks, ground_truth_input: test_ground_truth }) tf.logging.
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]]))
如何打印与所有类的预测相关联的概率
例如:
图1-A:0.5;B:0.3;C:0.1;D:0.1
图2-A:0.3;B:0.2;C:0:4;我想我自己找到了答案 概率可以这样获得:
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]))
然后,可以像这样访问它们:
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]))