KDrefine

September 28, 2024 ยท View on GitHub

Installation

This repo was tested with Ubuntu 20.04.4 LTS, Python 3.6, PyTorch 1.9.0, Torchvision 0.10.0 and CUDA 10.2.

Running

  1. Fetch the pretrained teacher models:

    sh scripts/fetch_pretrained_teachers.sh
    

    which will download and save the models to save/models

  2. An example of running KDrefine is given by:

    python train_student.py --path_t ./save/models/resnet110_vanilla/ckpt_epoch_240.pth --distill kdrefine --model_s represnet20 --blocktype AMBB  -r 0.1 -a 0.9 -b 0 --trial 1
    

3.Equivalent structural transformation:

```
python convert.py --arch represnet20 --blocktype AMBB --load `save/student_model/represnet20_last.pth` --save `save/student_model/represnet20_deploy.pth`
```

4. validation

Our models are at https://github.com/YujieZheng99/KDrefine/releases/tag/checkpoints

You can evaluate the performance of our models or models trained by yourself.

```
python validation.py --model represnet20 --model_path save/student_model/resnet110_2_resnet20_deploy_72.13.pth --blocktype AMBB --deploy_flag True
```

Benchmark Results on CIFAR-100:

We report the accuracy of last epoch and all results are average over 5 trials.

Teacher
Student
WRN-40-2
WRN-16-2
WRN-40-2
WRN-40-1
resnet56
resnet20
resnet110
resnet20
resnet110
resnet32
vgg13
vgg8
vgg13
mobilenetv2
resnet50
mobilenetv2
resnet50
vgg8
Teacher
Student
75.61
73.26
75.61
71.98
72.34
69.06
74.31
69.06
74.31
71.14
74.64
70.36
74.64
64.60
79.34
64.60
79.34
70.36
KD74.9273.5470.6670.6773.0872.9867.3767.3573.81
FitNet73.5872.2469.2168.9971.0671.0264.1463.1670.69
AT74.0872.7770.5570.2272.3171.4359.4058.5871.84
SP73.8372.4369.6770.0472.6972.6866.3068.0873.34
CC73.5672.2169.6369.4871.4870.7164.8665.4370.25
VID74.1173.3070.3870.1672.6171.2365.5667.5770.30
RKD73.3572.2269.6169.2571.8271.4864.5264.4371.50
PKT74.5473.4570.3470.2572.6172.8867.1366.5273.01
AB72.5072.3869.4769.5370.9870.9466.0667.2070.65
FT73.2571.5969.8470.2272.3770.5861.7860.9970.29
FSP72.91\69.9570.1171.8970.23\\\
NST73.6872.2469.6069.5371.9671.5358.1664.9671.28
CRD75.4874.1471.1671.4673.4873.9469.7369.1174.30
KDrefine75.9774.6271.8171.9974.0874.7068.9069.6074.88