
このレポはです
(1)主流のCVベンチマークで古典的な知識蒸留アルゴリズムを提供するPytorchライブラリ、
(2)CVPR-2022論文の公式実装:分離された知識蒸留。
(3)ICCV-2023論文の公式実装:DOT:蒸留指向のトレーナー。

CIFAR-100で:
| 教師 学生 | resnet32x4 Resnet8x4 | VGG13 VGG8 | resnet32x4 shufflenet-v2 |
|---|---|---|---|
| KD | 73.33 | 72.98 | 74.45 |
| KD+ドット | 75.12 | 73.77 | 75.55 |
Tiny-Imagenetで:
| 教師 学生 | resnet18 Mobilenet-V2 | resnet18 shufflenet-v2 |
|---|---|---|
| KD | 58.35 | 62.26 |
| KD+ドット | 64.01 | 65.75 |
Imagenet:
| 教師 学生 | ResNet34 resnet18 | Resnet50 Mobilenet-V1 |
|---|---|---|
| KD | 71.03 | 70.50 |
| KD+ドット | 71.72 | 73.09 |

CIFAR-100で:
| 教師 学生 | 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 |
| 教師 学生 | 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 |
Imagenet:
| 教師 学生 | ResNet34 resnet18 | Resnet50 Mobilenet-V1 |
|---|---|---|
| KD | 71.03 | 70.50 |
| DKD | 71.70 | 72.05 |
Mdistillerは、CIFAR-100、Imagenet、MS-Cocoで次の蒸留方法をサポートしています。
| 方法 | 紙のリンク | 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 | ✓✓ | ||
| ビデオ | 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 | ✓✓ | ✓✓ | ✓✓ |
環境:
パッケージをインストールします:
sudo pip3 install -r requirements.txt
sudo python3 setup.py develop
mdistiller/engine/cfg.pyでCFG.LOG.WANDB Falseとして設定します。自分で訓練されたモデルまたはモデルのパフォーマンスを評価できます。
私たちのモデルはhttps://github.com/megvii-research/mdistiller/releases/tag/checkpointsにあります./download_ckpts
Imagenetでモデルをテストする場合は、https://image-net.org/でデータセットをダウンロードして、 ./data/imagenet 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 checkpointscifar_teachers.tarをhttps://github.com/megvii-research/mdistiller/releases/tag/checkpointsからダウンロードし、 tar xvf cifar_teachers.tarを介して./download_ckptsに
# 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.1https://image-net.org/でデータセットをダウンロードして、 ./data/imagenetに置きます
# for instance, our DKD method.
python3 tools/train.py --cfg configs/imagenet/r34_r18/dkd.yamlmdistiller/distillers/にPythonファイルを作成し、蒸留器を定義します 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.
... mdistiller/distillers/__init__.pyで蒸留酒のdistiller_dict器をリジスト
mdistiller/engines/cfg.pyで対応するハイパーパラメータを登録します
新しい構成ファイルを作成してテストします。
このレポがあなたの研究に役立つ場合は、論文を引用することを検討してください。
@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はMITライセンスの下でリリースされます。詳細については、ライセンスを参照してください。
CRDとReviewKDをありがとう。 CRDのコードベースとReviewKDのコードベースに基づいてこのライブラリを構築します。
Megviiテクノロジーでのインターンシップ中のコード貢献について、Yiyu QiuとYi Shiに感謝します。
DKDについての議論をしてくれたXin Jinに感謝します。