
Este repo é
(1) Uma biblioteca Pytorch que fornece algoritmos de destilação de conhecimento clássico nos benchmarks de CV convencionais,
(2) A implementação oficial do artigo CVPR-2022: destilação de conhecimento dissociada.
(3) A implementação oficial do artigo ICCV-2023: DOT: um instrutor orientado a destilação.

No CIFAR-100:
| Professor Estudante | Resnet32x4 Resnet8x4 | VGG13 VGG8 | Resnet32x4 Shufflenet-v2 |
|---|---|---|---|
| KD | 73.33 | 72.98 | 74.45 |
| KD+DOT | 75.12 | 73.77 | 75.55 |
Em minúsculo imagenete:
| Professor Estudante | Resnet18 MobileNet-V2 | Resnet18 Shufflenet-v2 |
|---|---|---|
| KD | 58.35 | 62.26 |
| KD+DOT | 64.01 | 65.75 |
Na imagenet:
| Professor Estudante | Resnet34 Resnet18 | Resnet50 MobileNet-V1 |
|---|---|---|
| KD | 71.03 | 70.50 |
| KD+DOT | 71.72 | 73.09 |

No CIFAR-100:
| Professor Estudante | 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 |
| Professor Estudante | 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 |
Na imagenet:
| Professor Estudante | Resnet34 Resnet18 | Resnet50 MobileNet-V1 |
|---|---|---|
| KD | 71.03 | 70.50 |
| Dkd | 71.70 | 72.05 |
Mdistiller suporta os seguintes métodos de destilação no CIFAR-100, ImageNet e MS-COCO:
| Método | Link em papel | CIFAR-100 | Imagenet | MS-COCO |
|---|---|---|---|---|
| KD | https://arxiv.org/abs/1503.02531 | ✓ | ✓ | |
| FitNet | https://arxiv.org/abs/1412.6550 | ✓ | ||
| NO | 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 | ✓ | ✓ | |
| ReviewKD | https://arxiv.org/abs/2104.09044 | ✓ | ✓ | ✓ |
| Dkd | https://arxiv.org/abs/2203.08679 | ✓ | ✓ | ✓ |
Ambientes:
Instale o pacote:
sudo pip3 install -r requirements.txt
sudo python3 setup.py develop
CFG.LOG.WANDB como False em mdistiller/engine/cfg.py .Você pode avaliar o desempenho de nossos modelos ou modelos treinados por você mesmo.
Nossos modelos estão em https://github.com/megvii-research/mdistiller/releases/tag/checkpoints, faça o download dos pontos de verificação para ./download_ckpts
Se testar os modelos no ImageNet, faça o download do conjunto de dados em https://image-net.org/ e coloque-os em ./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 Faça o download do cifar_teachers.tar em https://github.com/megvii-research/mdistiller/releases/tag/checkpoints e não para ./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 Faça o download do conjunto de dados em https://image-net.org/ e coloque-os em ./data/imagenet
# for instance, our DKD method.
python3 tools/train.py --cfg configs/imagenet/r34_r18/dkd.yamlmdistiller/distillers/ e defina o 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.
... Regist o destilador em distiller_dict em mdistiller/distillers/__init__.py
Regista Os hiper-parâmetros correspondentes em mdistiller/engines/cfg.py
Crie um novo arquivo de configuração e teste -o.
Se este repositório for útil para sua pesquisa, considere citar o artigo:
@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 é liberado sob a licença do MIT. Consulte a licença para obter detalhes.
Obrigado pelo CRD e ReviewKD. Construímos essa biblioteca com base na base de código da CRD e na base de código do ReviewKD.
Obrigado Yiyu Qiu e Yi Shi pela contribuição do código durante o estágio na tecnologia Megvii.
Obrigado Xin Jin pela discussão sobre DKD.