This is an PyTorch implementation of MNN proposed by our paper MNN: Mixed Nearest-Neighbors for Self-Supervised Learning. If you find this repo useful, welcome 🌟🌟🌟✨.
To install requirements:
# name: d2lpy39
conda env create -f environment.yml
(You need to create the directory './stdout', you can also omit '>stdout/*' so that you can run these commands directly.) To train the model(s) in the paper, run those commands:
nohup python main.py --name mnn --momentum 0.99 --symmetric --weak --topk 5 --dataset cifar10 --gpuid 0 --logdir cifar10_00 --aug_numbers 2 --random_lamda >stdout/cifar10_00 2>&1 &
nohup python main.py --name mnn --momentum 0.99 --symmetric --weak --topk 5 --dataset cifar100 --gpuid 0 --logdir cifar100_00 --aug_numbers 2 --random_lamda >stdout/cifar100_00 2>&1 &
nohup python main.py --name mnn --momentum 0.996 --symmetric --weak --topk 5 --dataset tinyimagenet --gpuid 0 --logdir tinyimagenet_00 --aug_numbers 2 --queue_size 16384 --random_lamda >stdout/tinyimagenet_00 2>&1 &
To evaluate our model on CIFAR10/100 and Tiny-imagenet, run:
nohup python linear_eval.py --name mnn --dataset cifar10 --gpuid 0 --logdir cifar10_00 --seed 1339 >stdout/cifar10_00_01 2>&1 &
nohup python linear_eval.py --name mnn --dataset cifar100 --gpuid 0 --logdir cifar100_00 --seed 1339 >stdout/cifar100_00_01 2>&1 &
nohup python linear_eval.py --name mnn --dataset tinyimagenet --gpuid 0 --logdir tinyimagenet_00 --seed 1339 >stdout/tinyimagenet_00_01 2>&1 &
You can download pretrained models here:
- this link trained on three datasets.
- Download and place in the "./checkpoints" directory
Our model achieves the following performance:
- | CIFAR-10 | CIFAR-100 | Tiny ImageNet |
---|---|---|---|
MSF | 90.19 | 59.22 | 42.68 |
MNN(Ours) | 91.47 | 67.56 | 50.70 |
📋 If there are any questions, feel free to contact with the authors.