DoctorKey / LSHFM.singleclassification

Single-class image classification of Distilling Knowledge by Mimicking Features.
6 stars 3 forks source link
image-classification knowledge-distillation python3 pytorch

LSHFM.classification

PWC PWC PWC

This is the PyTorch source code for Distilling Knowledge by Mimicking Features. We provide all codes for three tasks.

Dependence

Prepare the dataset

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.

CIFAR-100

Teacher:

Student:

Train vanilla teacher and 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

Feature mimicking & knowledge distillation

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

Imagenet

Please use the below command to run experiments:

python imagenet_lsh.py /mnt/ramdisk/ImageNet --gpus 0,1 -a ResNet18 --teacher-arch ResNet34 

Citing this repository

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},
}

Acknowledgement