【发布时间】: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