
Ce repo est
(1) Une bibliothèque Pytorch qui fournit des algorithmes de distillation de connaissances classiques sur les repères CV traditionnels,
(2) La mise en œuvre officielle du document CVPR-2022: distillation des connaissances découplées.
(3) La mise en œuvre officielle du document ICCV-2023: DOT: un entraîneur axé sur la distillation.

Sur CIFAR-100:
| Professeur Étudiant | Resnet32x4 Resnet8x4 | VGG13 VGG8 | Resnet32x4 Shufflenet-v2 |
|---|---|---|---|
| Kd | 73.33 | 72.98 | 74.45 |
| Kd + point | 75.12 | 73.77 | 75.55 |
Sur Tiny-Imagenet:
| Professeur Étudiant | Resnet18 Mobilenet-v2 | Resnet18 Shufflenet-v2 |
|---|---|---|
| Kd | 58,35 | 62.26 |
| Kd + point | 64.01 | 65,75 |
Sur Imagenet:
| Professeur Étudiant | Resnet34 Resnet18 | Resnet50 Mobilenet-v1 |
|---|---|---|
| Kd | 71.03 | 70.50 |
| Kd + point | 71.72 | 73.09 |

Sur CIFAR-100:
| Professeur Étudiant | Resnet56 Resnet20 | Resnet110 Resnet32 | Resnet32x4 Resnet8x4 | WRN-40-2 WRN-16-2 | WRN-40-2 WRN-40-1 | VGG13 VGG8 |
|---|---|---|---|---|---|---|
| Kd | 70,66 | 73.08 | 73.33 | 74.92 | 73.54 | 72.98 |
| DKD | 71.97 | 74.11 | 76.32 | 76.23 | 74.81 | 74.68 |
| Professeur Étudiant | Resnet32x4 Shufflenet-v1 | WRN-40-2 Shufflenet-v1 | VGG13 Mobilenet-v2 | Resnet50 Mobilenet-v2 | Resnet32x4 Mobilenet-v2 |
|---|---|---|---|---|---|
| Kd | 74.07 | 74.83 | 67.37 | 67,35 | 74.45 |
| DKD | 76.45 | 76.70 | 69.71 | 70,35 | 77.07 |
Sur Imagenet:
| Professeur Étudiant | Resnet34 Resnet18 | Resnet50 Mobilenet-v1 |
|---|---|---|
| Kd | 71.03 | 70.50 |
| DKD | 71.70 | 72.05 |
MDISTILLER prend en charge les méthodes de distillation suivantes sur CIFAR-100, IMAMENET et MS-COCO:
| Méthode | Lien papier | CIFAR-100 | Imagenet | MS-COCO |
|---|---|---|---|---|
| Kd | https://arxiv.org/abs/1503.02531 | ✓ | ✓ | |
| Fitnet | https://arxiv.org/abs/1412.6550 | ✓ | ||
| À | https://arxiv.org/abs/1612.03928 | ✓ | ✓ | |
| NST | https://arxiv.org/abs/1707.01219 | ✓ | ||
| Pkt | https://arxiv.org/abs/1803.10837 | ✓ | ||
| KDSVD | https://arxiv.org/abs/1807.06819 | ✓ | ||
| Ofd | https://arxiv.org/abs/1904.01866 | ✓ | ✓ | |
| RKD | https://arxiv.org/abs/1904.05068 | ✓ | ||
| Vid | https://arxiv.org/abs/1904.05835 | ✓ | ||
| Sp | https://arxiv.org/abs/1907.09682 | ✓ | ||
| CRD | https://arxiv.org/abs/1910.10699 | ✓ | ✓ | |
| Revuekd | https://arxiv.org/abs/2104.09044 | ✓ | ✓ | ✓ |
| DKD | https://arxiv.org/abs/2203.08679 | ✓ | ✓ | ✓ |
Environnements:
Installez le package:
sudo pip3 install -r requirements.txt
sudo python3 setup.py develop
CFG.LOG.WANDB comme False sur mdistiller/engine/cfg.pyVous pouvez évaluer les performances de nos modèles ou modèles formés par vous-même.
Nos modèles sont sur https://github.com/megvii-research/mdistller/releases/tag/checkpoints, veuillez télécharger les points de contrôle sur ./download_ckpts
Si testez les modèles sur ImageNet, veuillez télécharger l'ensemble de données sur https://image-net.org/ et les mettre sur ./data/imagenet
# evaluate teachers
python3 tools/eval.py -m resnet32x4 # resnet32x4 on cifar100
python3 tools/eval.py -m ResNet34 -d imagenet # ResNet34 on imagenet
# evaluate students
python3 tools/eval.p -m resnet8x4 -c download_ckpts/dkd_resnet8x4 # dkd-resnet8x4 on cifar100
python3 tools/eval.p -m MobileNetV1 -c download_ckpts/imgnet_dkd_mv1 -d imagenet # dkd-mv1 on imagenet
python3 tools/eval.p -m model_name -c output/your_exp/student_best # your checkpoints Téléchargez le cifar_teachers.tar sur https://github.com/megvii-research/mDistiller/releases/tag/checkpoints et unptar à ./download_ckpts via tar xvf cifar_teachers.tar .
# for instance, our DKD method.
python3 tools/train.py --cfg configs/cifar100/dkd/res32x4_res8x4.yaml
# you can also change settings at command line
python3 tools/train.py --cfg configs/cifar100/dkd/res32x4_res8x4.yaml SOLVER.BATCH_SIZE 128 SOLVER.LR 0.1 Téléchargez l'ensemble de données sur https://image-net.org/ et mettez-les sur ./data/imagenet
# for instance, our DKD method.
python3 tools/train.py --cfg configs/imagenet/r34_r18/dkd.yamlmdistiller/distillers/ ET DÉFINIR LE DISTILLER from . _base import Distiller
class MyDistiller ( Distiller ):
def __init__ ( self , student , teacher , cfg ):
super ( MyDistiller , self ). __init__ ( student , teacher )
self . hyper1 = cfg . MyDistiller . hyper1
...
def forward_train ( self , image , target , ** kwargs ):
# return the output logits and a Dict of losses
...
# rewrite the get_learnable_parameters function if there are more nn modules for distillation.
# rewrite the get_extra_parameters if you want to obtain the extra cost.
... Registre le distillateur dans distiller_dict à mdistiller/distillers/__init__.py
Régistent les hyper-paramètres correspondants à mdistiller/engines/cfg.py
Créez un nouveau fichier de configuration et testez-le.
Si ce dépôt est utile pour vos recherches, veuillez envisager de citer le document:
@article { zhao2022dkd ,
title = { Decoupled Knowledge Distillation } ,
author = { Zhao, Borui and Cui, Quan and Song, Renjie and Qiu, Yiyu and Liang, Jiajun } ,
journal = { arXiv preprint arXiv:2203.08679 } ,
year = { 2022 }
}
@article { zhao2023dot ,
title = { DOT: A Distillation-Oriented Trainer } ,
author = { Zhao, Borui and Cui, Quan and Song, Renjie and Liang, Jiajun } ,
journal = { arXiv preprint arXiv:2307.08436 } ,
year = { 2023 }
}MDISTILLER est libéré sous la licence du MIT. Voir la licence pour plus de détails.
Merci pour CRD et Reviewkd. Nous construisons cette bibliothèque en fonction de la base de code du CRD et de la base de code de ReviewKD.
Merci Yiyu Qiu et Yi Shi pour la contribution du code lors de leur stage dans la technologie MEGVII.
Merci Xin Jin pour la discussion sur DKD.