如何在张量流中查看按类别分类的准确度?

问题描述 投票:0回答:1

我正在尝试使用具有N = 26个类的softmax分类器来创建神经网络。初步结果似乎很有希望,但我需要了解按类别划分的准确性。经过150个时间段后,测试准确性为71.1%,但总共有26个课程。我敢肯定有些班级做得很好,有些班级做得很差,我需要知道每个班级的准确率和准确率。

我花了个搜索,无法弄清楚该如何获得。似乎这是某人需要的基本,简单的obvious东西,因此我怀疑我只是缺少了一些东西。

我尝试过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%。) >

我正在尝试使用具有N = 26个类的softmax分类器来创建神经网络。初步结果似乎很有希望,但我需要了解按类别划分的准确性。 150个纪元后,测试...

python tensorflow softmax
1个回答
0
投票

假设您满足于在训练后而不是在训练中查找类级别的准确性,则只需在测试集上简单地predict模型输出,然​​后通过例如存储每个项目的命中和未命中来自己检查准确性数组中的26个类。

© www.soinside.com 2019 - 2024. All rights reserved.