1Department of Computer Science and Technology, Harbin Institute of Technology (Shenzhen), China
2School of Software, Tsinghua University, China
3Alibaba Group, China
4School of Computer Science and Technology, Shandong University, China
Knowledge distillation transfers knowledge from a large teacher network to a compact student network. Existing methods usually align instance-level logits or features, but they often ignore two useful signals:
- category-level information from the classifier weights, which can be viewed as category centers;
- sample difficulty, because hard samples should not be treated exactly like easy samples at the beginning of training.
PCKD addresses these issues with two components:
- Category Contrastive Learning for Knowledge Distillation (CKD): distills feature representations, category centers, and their correlations. In code, the core category contrastive loss is implemented as
CategoryConLossinhelper/losses.py. - Preview-based Learning Strategy: dynamically weights each sample according to its difficulty. Hard samples receive smaller weights early in training and gradually contribute more as training proceeds. The weighting logic is implemented in the
pckdbranch ofhelper/loops.py.
The paper evaluates PCKD on CIFAR-100, ImageNet, STL-10, and TinyImageNet. This code release focuses on the CIFAR-100 training pipeline and related KD baselines inherited from the RepDistiller/CRD codebase.
Before training a student, prepare:
- CIFAR-100 in Python format. The expected raw folder name is
cifar-100-python. - A pretrained teacher checkpoint. The student script expects
--path_tto point to a checkpoint whose dictionary contains the keymodel.
The current dataloader uses the dataset root configured in dataset/cifar100.py. Adjust get_data_folder() there to your local dataset path before running if needed.
Teacher checkpoints are commonly placed under:
save/models/<teacher_run_name>/<teacher_model>_best.pth
For example:
save/models/wrn_40_2_cifar100_lr_0.05_decay_0.0005_trial_0/wrn_40_2_best.pth
python train_student.py \
--path_t teacher_pth \
--distill pckd \
-r 1 -a 1 -b 0.05 -f 20 \
--model_s wrn_16_2 \
--dataset cifar100PCKD improves over KD and strong distillation baselines on CIFAR-100 for both same-family and heterogeneous teacher/student pairs. The paper also reports:
If you find this repository useful, please cite:
@article{ding2025pckd,
title={Preview-based Category Contrastive Learning for Knowledge Distillation},
author={Ding, Muhe and Wu, Jianlong and Dong, Xue and Li, Xiaojie and Qin, Pengda and Gan, Tian and Nie, Liqiang},
journal={IEEE Transactions on Circuits and Systems for Video Technology},
year={2025}
}This work is built on the following repositories. Thanks to their great work.

