【问题标题】:Mean average precision (mAP) in tensorflow张量流中的平均精度(mAP)
【发布时间】:2021-06-17 18:04:39
【问题描述】:

我需要使用 Tensorflow 计算此 question 中描述的 mAP 以进行对象检测

平均精度 (AP) 是用于排名集的典型性能度量。 AveragePrecision 定义为范围 S 中每个真阳性、TP 之后的精度分数的平均值。给定一个范围 S = 7,和一个排名列表(增益向量) G = [1,1,0,1,1,0 ,0,1,1,0,1,0,0,..] 其中 1/0 分别表示与相关/非相关项目相关的增益:

AP = (1/1 + 2/2 + 3/4 + 4/5) / 4 = 0.8875。

平均平均精度 (mAP):一组查询的平均精度值的平均值。

我得到了 5 个带有预测的 One-Hot 张量:

prediction_A 
prediction_B
prediction_C 
prediction_D 
prediction_E 

其中单个预测张量具有这种结构(例如 prediction_A):

00100
01000
00001
00010
00010

然后我得到了正确的标签(one-hot)张量,具有相同的结构:

y_A
y_B
y_C
y_D
y_E

我想使用 tensorflow 计算 mAP,因为我想总结一下,我该怎么做?

我找到了这个function,但我不能使用它,因为我有一个多维向量。

我还写了一个 Python 函数来计算 AP 但它不使用 Tensorflow

def compute_av_precision(match_list):
    n = len(match_list)
    tp_counter = 0

    cumulate_precision = 0
    for i in range(0,n):
        if match_list[i] == True:

            tp_counter += 1

            cumulate_precision += (float(tp_counter)/float(i+1))


    if tp_counter != 0:
        av_precision = cumulate_precision/float(tp_counter)
        return av_precision
    return 0

【问题讨论】:

    标签: python tensorflow average-precision


    【解决方案1】:

    我想你可能需要这个:

    tf.metrics.average_precision_at_k
    

    此方法使用标签和预测来计算您提到的 AP@K

    以下是参考链接

    https://www.tensorflow.org/api_docs/python/tf/metrics/average_precision_at_k

    实现了此处定义的 AP@K 指标:

    https://en.wikipedia.org/wiki/Evaluation_measures_(information_retrieval)#Average_precision

    顺便说一句,如果您需要 Tensorflow 中的指标,首先您应该在他们的官方文档中搜索。以下是所有已实施指标的列表

    https://www.tensorflow.org/api_docs/python/tf/metrics

    干杯

    【讨论】:

    • 我认为这不是一个完整的答案,mAP和你说的不一样,因为我们需要牢记IOU。
    猜你喜欢
    • 2018-01-31
    • 1970-01-01
    • 1970-01-01
    • 2015-08-14
    • 2018-11-25
    • 1970-01-01
    • 2016-06-13
    • 2020-09-30
    • 1970-01-01
    相关资源
    最近更新 更多