This is the PyTorch source code for Distilling Knowledge by Mimicking Features. We provide all codes for three tasks.
Please prepare the COCO and VOC datasets by youself. Then you need to check and edit the get_data_path
function in src/dataset/coco_utils.py
and src/dataset/voc_utils.py
.
Teacher:
Student:
Train the teacher:
python train_vanilla.py --model [teacher network] --gpus 0
e.g.
python train_vanilla.py --model resnet56 --gpus 0
Train the student:
python train_vanilla.py --model [student network] --gpus 0
e.g.
python train_vanilla.py --model wrn_16_2 --gpus 0
Please use the below command to run experiments:
python train_student.py --model_s [student network] --path_t [path to the teacher] --gpus 0
e.g.
python train_student.py --model_s wrn_16_2 --path_t save/models/wrn_40_2_vanilla/ckpt_epoch_240.pth --gpus 0
Please use the below command to run experiments:
python imagenet_lsh.py /mnt/ramdisk/ImageNet --gpus 0,1 -a ResNet18 --teacher-arch ResNet34
If you find this code useful in your research, please consider citing us:
@article{LSHFM,
title={Distilling knowledge by mimicking features},
author={Wang, Guo-Hua and Ge, Yifan and Wu, Jianxin},
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
year={2021},
}