18 lines
515 B
Python
Raw Normal View History

2022-05-30 03:23:58 +00:00
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmselfsup.evaluation import knn_eval
2022-05-30 03:23:58 +00:00
def test_knn_eval():
2022-05-30 03:23:58 +00:00
train_feats = torch.ones(200, 3)
train_labels = torch.ones(200).long()
test_feats = torch.ones(200, 3)
test_labels = torch.ones(200).long()
num_knn = [10, 20, 100, 200]
for k in num_knn:
top1, top5 = knn_eval(train_feats, train_labels, test_feats,
test_labels, k, 0.07)
2022-05-30 03:23:58 +00:00
assert top1 == 100.
assert top5 == 100.