Yixiao Fang 5e44bf7179 [Refactor] Refactor evaluation folder and related configs (#538)
* refactor evaluation folder

* update knn script

* update ut

* update configs

* update config names according to mmdet and mmseg

* update docs
2022-11-03 16:09:36 +08:00

18 lines
515 B
Python

# Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmselfsup.evaluation import knn_eval
def test_knn_eval():
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)
assert top1 == 100.
assert top5 == 100.