ViTKD: Practical Guidelines for ViT feature knowledge distillation

Zhendong Yang, Zhe Li, Ailing Zeng, Zexian Li, Chun Yuan +1 more
9/6/2022
cs.CV
transformer-attentiondistillation

Official code: yzd-v/cls_KD (254 stars, Python, Apache-2.0, PyTorch, last commit 2023-10-10).

Abstract

Knowledge Distillation (KD) for Convolutional Neural Network (CNN) is extensively studied as a way to boost the performance of a small model. Recently, Vision Transformer (ViT) has achieved great success on many computer vision tasks and KD for ViT is also desired.

Show full abstract

However, besides the output logit-based KD, other feature-based KD methods for CNNs cannot be directly applied to ViT due to the huge structure gap. In this paper, we explore the way of feature-based distillation for ViT. Based on the nature of feature maps in ViT, we design a series of controlled experiments and derive three practical guidelines for ViT's feature distillation. Some of our findings are even opposite to the practices in the CNN era. Based on the three guidelines, we propose our feature-based method ViTKD which brings consistent and considerable improvement to the student. On ImageNet-1k, we boost DeiT-Tiny from 74.42% to 76.06%, DeiT-Small from 80.55% to 81.95%, and DeiT-Base from 81.76% to 83.46%. Moreover, ViTKD and the logit-based KD method are complementary and can be applied together directly. This combination can further improve the performance of the student. Specifically, the student DeiT-Tiny, Small, and Base achieve 77.78%, 83.59%, and 85.41%, respectively. The code is available at https://github.com/yzd-v/cls_KD.

View on arXivView PDF

Code Implementations(1)

yzd-v/cls_KDOfficial100%
PyTorchApache-2.0

'NKD and USKD' (ICCV 2023) and 'ViTKD' (CVPRW 2024)

25419Python, DockerfileAug 19, 20223 years agoApache-2.0
image-classificationknowledge-distillationpytorchself-knowledge-distillationvision-transformer

Similar Papers

Cite this paper

@article{yang2022vitkd,
  title  = {ViTKD: Practical Guidelines for ViT feature knowledge distillation},
  author = {Zhendong Yang and Zhe Li and Ailing Zeng and Zexian Li and Chun Yuan and Yu Li},
  year   = {2022},
  eprint = {2209.02432},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2209.02432}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2209.02432.svg)](https://codeofpaper.com/paper/2209.02432)

Discussion