Skip to content

Question about eval university1652 code #46

@szyfh

Description

@szyfh

Great work!
In function compute_mAP
`def compute_mAP(index, good_index, junk_index):
ap = 0
cmc = torch.IntTensor(len(index)).zero_()
if good_index.size==0: # if empty
cmc[0] = -1
return ap,cmc

# remove junk_index
mask = np.in1d(index, junk_index, invert=True)
index = index[mask]

# find good_index index
ngood = len(good_index)
mask = np.in1d(index, good_index)
rows_good = np.argwhere(mask==True)  
rows_good = rows_good.flatten()

cmc[rows_good[0]:] = 1
for i in range(ngood):
    d_recall = 1.0/ngood
    precision = (i+1)*1.0/(rows_good[i]+1)
    if rows_good[i]!=0:
        old_precision = i*1.0/rows_good[i]
    else:
        old_precision=1.0
    ap = ap + d_recall*(old_precision + precision)/2

return ap, cmc`

rows_good represents the indices after filtering out junk_index, while cmc is of the original length. This causes a mismatch in indices. So is there any code mistakes?
Looking forward to your reply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions