in matching_network.py [0:0]
def run_test(model, G, G_norm, Y, test_file_handle, base_classes, novel_classes, batchsize=128):
count = test_file_handle['count'][0]
all_feats = test_file_handle['all_feats']
all_labels = test_file_handle['all_labels'][:count]
top1 = None
top5 = None
for i in range(0, count, batchsize):
stop = min(i+batchsize, count)
F = all_feats[range(i,stop)]
F = Variable(torch.Tensor(F).cuda())
L = all_labels[i:stop]
scores = model.get_logprobs(F, G, G_norm, Y)
top1_this, top5_this = perelement_accuracy(scores.data, L)
top1 = top1_this if top1 is None else np.concatenate((top1, top1_this))
top5 = top5_this if top5 is None else np.concatenate((top5, top5_this))
is_novel = np.in1d(all_labels, novel_classes)
is_base = np.in1d(all_labels, base_classes)
is_either = is_novel | is_base
top1_novel = np.mean(top1[is_novel])
top1_base = np.mean(top1[is_base])
top1_all = np.mean(top1[is_either])
top5_novel = np.mean(top5[is_novel])
top5_base = np.mean(top5[is_base])
top5_all = np.mean(top5[is_either])
return np.array([top1_novel, top5_novel, top1_base, top5_base, top1_all, top5_all])