
Este repositorio es
(1) Una biblioteca de Pytorch que proporciona algoritmos de destilación de conocimiento clásico en los principales puntos de referencia de CV,
(2) La implementación oficial del documento CVPR-2022: destilación de conocimiento desacoplado.
(3) La implementación oficial del documento ICCV-2023: DOT: un entrenador orientado a la destilación.

En CIFAR-100:
| Maestro Alumno | Resnet32x4 Resnet8x4 | VGG13 VGG8 | Resnet32x4 Shufflenet-v2 |
|---|---|---|---|
| KD | 73.33 | 72.98 | 74.45 |
| KD+punto | 75.12 | 73.77 | 75.55 |
En Tiny-iMagenet:
| Maestro Alumno | Resnet18 Mobilenet-v2 | Resnet18 Shufflenet-v2 |
|---|---|---|
| KD | 58.35 | 62.26 |
| KD+punto | 64.01 | 65.75 |
En Imagenet:
| Maestro Alumno | Resnet34 Resnet18 | Resnet50 Mobilenet-v1 |
|---|---|---|
| KD | 71.03 | 70.50 |
| KD+punto | 71.72 | 73.09 |

En CIFAR-100:
| Maestro Alumno | 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 |
| Maestro Alumno | 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 |
En Imagenet:
| Maestro Alumno | Resnet34 Resnet18 | Resnet50 Mobilenet-v1 |
|---|---|---|
| KD | 71.03 | 70.50 |
| DKD | 71.70 | 72.05 |
Mdistiller admite los siguientes métodos de destilación en CIFAR-100, Imagenet y MS-Coco:
| Método | Enlace de papel | Cifar-100 | Imagenet | MS-Coco |
|---|---|---|---|---|
| KD | https://arxiv.org/abs/1503.02531 | ✓ | ✓ | |
| Fit | https://arxiv.org/abs/1412.6550 | ✓ | ||
| EN | 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 | ✓ | ||
| De color | https://arxiv.org/abs/1904.01866 | ✓ | ✓ | |
| RKD | https://arxiv.org/abs/1904.05068 | ✓ | ||
| Vía | https://arxiv.org/abs/1904.05835 | ✓ | ||
| Sp | https://arxiv.org/abs/1907.09682 | ✓ | ||
| CRD | https://arxiv.org/abs/1910.10699 | ✓ | ✓ | |
| Reviewkd | https://arxiv.org/abs/2104.09044 | ✓ | ✓ | ✓ |
| DKD | https://arxiv.org/abs/2203.08679 | ✓ | ✓ | ✓ |
Entornos:
Instale el paquete:
sudo pip3 install -r requirements.txt
sudo python3 setup.py develop
CFG.LOG.WANDB como False en mdistiller/engine/cfg.py .Puede evaluar el rendimiento de nuestros modelos o modelos capacitados por usted mismo.
Nuestros modelos están en https://github.com/megvii-research/mdistiller/releases/tag/checkpoints, descargue los puntos de control a ./download_ckpts
Si prueba los modelos en ImageNet, descargue el conjunto de datos en https://image-net.org/ y póngalos en ./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 Descargue cifar_teachers.tar en https://github.com/megvii-research/mdistiller/releases/tag/checkpoints y destartelo a ./download_ckpts a través de 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 Descargue el conjunto de datos en https://image-net.org/ y póngalos en ./data/imagenet
# for instance, our DKD method.
python3 tools/train.py --cfg configs/imagenet/r34_r18/dkd.yamlmdistiller/distillers/ y defina el destilador 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.
... Registe el destilador en distiller_dict en mdistiller/distillers/__init__.py
Registen los hiperparametros correspondientes en mdistiller/engines/cfg.py
Cree un nuevo archivo de configuración y pruebelo.
Si este repositorio es útil para su investigación, considere citar el documento:
@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 se libera bajo la licencia MIT. Vea la licencia para más detalles.
Gracias por CRD y Reviewkd. Construimos esta biblioteca basada en la base de código de la CRD y la base de código de revisión de ReviewKD.
Gracias Yiyu Qiu y Yi Shi por la contribución del código durante su pasantía en tecnología MEGVII.
Gracias Xin Jin por la discusión sobre DKD.