-2

我已经通过Tensorflow Hub训练了一个基于迁移学习的模型。我一直在很多地方寻找有关生成混淆矩阵的提示,但我无法找到正确的解决方案。

有谁知道这是否可能?

我尝试的最后一件事是将结果写在 Excel 工作表中,但我在 Excel 中找不到用于混淆矩阵的多类计算的公式。

任何帮助都会很棒!

4

1 回答 1

0

你可以试试tf.math.confusion_matrix函数。
它根据预测和标签计算混淆矩阵。
请参阅https://www.tensorflow.org/api_docs/python/tf/math/confusion_matrix

例子:

my_confusion_matrix = tf.math.confusion_matrix(labels=[1, 2, 4], predictions=[2, 2, 3])
with tf.Session() as sess:
  print(sess.run(my_confusion_matrix))

# Prints #
[[0 0 0 0 0]
 [0 0 1 0 0]
 [0 0 1 0 0]
 [0 0 0 0 0]
 [0 0 0 1 0]]

# Labels are assumed to be [0, 1, 2, 3, 4] thus resulting in 5X5 confusion matrix
于 2019-08-24T19:38:05.657 回答