平均精度(mAP)(以十为单位)

2024-06-10 19:50:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要使用Tensorflow计算本question中所描述的映射,以便使用Tensorflow进行对象检测。

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

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

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

我得到了5个热张量,预测如下:

prediction_A 
prediction_B
prediction_C 
prediction_D 
prediction_E 

当一个预测张量具有这种结构时(例如,预测:

00100
01000
00001
00010
00010

然后我得到了正确的标签(一个热的)张量,具有相同的结构:

y_A
y_B
y_C
y_D
y_E

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

我找到了这个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

Tags: tensorflowmatchcounter精度float结构向量list