Home

Awesome

SSKD

This repo is the implementation of paper Knowledge Distillation Meets Self-Supervision (ECCV 2020).

<img src="https://github.com/xuguodong03/SSKD/raw/master/frm.png" width="100%" height="100%">

Prerequisite

This repo is tested with Ubuntu 16.04.5, Python 3.7, PyTorch 1.5.0, CUDA 10.2. Make sure to install pytorch, torchvision, tensorboardX, numpy before using this repo.

Running

Teacher Training

An example of teacher training is:

python teacher.py --arch wrn_40_2 --lr 0.05 --gpu-id 0

where you can specify the architecture via flag --arch

You can also download all the pre-trained teacher models here. If you want to run student.py directly, you have to re-organise the directory. For instance, when you download vgg13.pth, you have to make a directory for it, say teacher_vgg13, and then make a new directory ckpt inside teacher_vgg13. Move the vgg13.pth into teacher_vgg13/ckpt and rename it as best.pth. If you want a simpler way to use pre-trained model, you can edit the code in student.py (line 90).

Student Training

An example of student training is:

python student.py --t-path ./experiments/teacher_wrn_40_2_seed0/ --s-arch wrn_16_2 --lr 0.05 --gpu-id 0

The meanings of flags are:

--t-path: teacher's checkpoint path. Automatically search the checkpoint containing 'best' keyword in its name.

--s-arch: student's architecture.

All the commands can be found in command.sh

Results (Top-1 Acc) on CIFAR100

Similar-Architecture

Teacher <br> Studentwrn40-2 <br> wrn16-2wrn40-2 <br> wrn40-1resnet56 <br> resnet20resnet32x4 <br> resnet8x4vgg13 <br> vgg8
Teacher <br> Student76.46 <br> 73.6476.46 <br> 72.2473.44 <br> 69.6379.63 <br> 72.5175.38 <br> 70.68
KD74.9273.5470.6673.3372.98
FitNet75.7574.1271.6074.3173.54
AT75.2874.4571.7874.2673.62
SP75.3473.1571.4874.7473.44
VID74.7974.2071.7174.8273.96
RKD75.4073.8771.4874.4773.72
PKT76.0174.4071.4474.1773.37
AB68.8975.0671.4974.4574.27
FT75.1574.3771.5275.0273.42
CRD76.0475.5271.6875.9074.06
SSKD76.0476.1371.4976.2075.33

Cross-Architecture

Teacher <br> Studentvgg13 <br> MobieleNetV2ResNet50 <br> MobileNetV2ResNet50 <br> vgg8resnet32x4 <br> ShuffleV1resnet32x4 <br> ShuffleV2wrn40-2 <br> ShuffleV1
Teacher <br> Student75.38 <br> 65.7979.10 <br> 65.7979.10 <br> 70.6879.63 <br> 70.7779.63 <br> 73.1276.46 <br> 70.77
KD67.3767.3573.8174.0774.4574.83
FitNet68.5868.5473.8474.8275.1175.55
AT69.3469.2873.4574.7675.3075.61
SP66.8968.9973.8673.8075.1575.56
VID66.9168.8873.7574.2875.7875.36
RKD68.5068.4673.7374.2075.7475.45
PKT67.8968.4473.5374.0675.1875.51
AB68.8669.3274.2076.2475.6676.58
FT69.1969.0173.5874.3174.9575.18
CRD68.4970.3274.4275.4675.7275.96
SSKD71.5372.5775.7678.4478.6177.40

Citation

If you find this repo useful for your research, please consider citing the paper

@inproceedings{xu2020knowledge,
    title={Knowledge Distillation Meets Self-Supervision},
    author={Xu, Guodong and Liu, Ziwei and Li, Xiaoxiao and Loy, Chen Change},
    booktitle={European Conference on Computer Vision (ECCV)},
    year={2020},
}

Acknowledgement

The implementation of models is borrowed from CRD