【发布时间】:2019-04-18 21:24:33
【问题描述】:
我正在使用add_metric 尝试创建一个自定义指标来计算分类器的前 3 位准确度。据我所知,这是:
def custom_metrics(labels, predictions):
# labels => Tensor("fifo_queue_DequeueUpTo:422", shape=(?,), dtype=int64)
# predictions => {
# 'logits': <tf.Tensor 'dnn/logits/BiasAdd:0' shape=(?, 26) dtype=float32>,
# 'probabilities': <tf.Tensor 'dnn/head/predictions/probabilities:0' shape=(?, 26) dtype=float32>,
# 'class_ids': <tf.Tensor 'dnn/head/predictions/ExpandDims:0' shape=(?, 1) dtype=int64>,
# 'classes': <tf.Tensor 'dnn/head/predictions/str_classes:0' shape=(?, 1) dtype=string>
# }
看现有tf.metrics的实现,一切都是使用tf ops实现的。我怎样才能实现前 3 名的准确性?
【问题讨论】:
标签: python tensorflow metrics top-n