【发布时间】:2019-12-31 19:05:48
【问题描述】:
我正在尝试使用具有 N=26 个类的 softmax 分类器创建神经网络。初步结果似乎很有希望,但我需要知道按类别划分的准确性。在 150 个 epoch 之后,测试准确率为 71.1%,但这是 26 个类的总数。我确信有些课程做得很好,有些课程做得很差,我需要知道每个课程的准确度和准确度。
我已经花了 天 搜索,但不知道如何得到它。这似乎是某人需要的基本、简单、显而易见的东西,所以我怀疑我只是遗漏了一些东西。
我试过print(tf.print(tf.compat.v1.metrics.mean_per_class_accuracy(labels, logits, n)))但得到了
name: "PrintV2"
op: "PrintV2"
input: "StringFormat"
attr {
key: "end"
value {
s: "\n"
}
}
attr {
key: "output_stream"
value {
s: "stderr"
}
}
我尝试删除 tf.print 并尝试print(tf.compat.v1.metrics.mean_per_class_accuracy(labels, logits, n)),但得到了(<tf.Tensor 'mean_accuracy/mean_accuracy:0' shape=() dtype=float32>, <tf.Tensor 'mean_accuracy/update_op:0' shape=(27,) dtype=float32>)。从技术上讲,它们都不是错误,但它们也没有告诉我我需要知道什么。
我还尝试了print(classification_report(labels, logits)) 和print(classification_report(labels, tf.argmax(logits))),它们都给了我错误TypeError: object of type 'Tensor' has no len()。 Logits 是张量。我一直无法找到将其转换为数组或向量的方法,甚至无法打印它的内容。
如何查看按类别划分的准确率? (如果我的意思不是很明显,当 71% 是整体准确率时,我希望它告诉我,例如:1 类 = 82%,...,N 类 = 13%。)
【问题讨论】:
标签: python tensorflow softmax