mirror of
https://github.com/open-mmlab/mmselfsup.git
synced 2025-06-03 14:59:38 +08:00
* refactor evaluation folder * update knn script * update ut * update configs * update config names according to mmdet and mmseg * update docs
18 lines
515 B
Python
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.
|