Cross-Architecture Knowledge Distillation

Yufan Liu, Jiajiong Cao, Bing Li, Weiming Hu, Jingting Ding, Liang Li, Stephen J. MaybankIJCV 2022

TL;DR

This paper introduces a novel method for "cross-architecture knowledge distillation," enabling compact CNN models to learn from powerful Transformer models. By developing specialized "projectors" and a robust training scheme, they significantly improve knowledge transfer between these distinct network types, leading to better performance on various computer vision tasks.

What Problem Does This Paper Address?

The field of deep learning has seen the rise of Transformer networks, which excel at capturing long-range dependencies and global relationships in data, leading to state-of-the-art performance in many computer vision tasks. However, Transformers are computationally expensive and less amenable to hardware acceleration, especially on edge devices. Convolutional Neural Networks (CNNs), on the other hand, are more efficient and widely supported by hardware.

Knowledge Distillation (KD) is a technique where a smaller "student" model learns from a larger, pre-trained "teacher" model. Traditionally, KD methods have focused on scenarios where the teacher and student have the same architecture (e.g., CNN to CNN). This paper addresses the challenge of cross-architecture KD, specifically distilling knowledge from a Transformer teacher to a CNN student. The core problem is the significant architectural and representational gap between these two types of networks, making direct knowledge transfer difficult and less effective, as evidenced by low "knowledge transferability" scores in prior work.

Methods

The authors propose a novel cross-architecture knowledge distillation framework to bridge the gap between Transformers and CNNs. The key innovations are:

  • Cross-Architecture Projectors: Instead of directly mimicking teacher outputs, they introduce two projectors to align student features with teacher features in projected spaces:
  • Partially Cross Attention (PCA) Projector: This maps CNN student features into the Transformer's attention space. It encourages the student to learn global relationships by aligning attention maps between the teacher and student.
  • Group-wise Linear (GL) Projector: This maps student features into the Transformer's feature space in a pixel-by-pixel manner, directly addressing feature formation differences. To manage computational cost, a group-wise approach is used, where neighboring pixels share a linear projection.
  • Multi-View Robust Training Scheme: To combat the instability inherent in cross-architecture KD, they propose a scheme involving:
  • Multi-View Generator (MVG): This creates transformed versions of the input data (e.g., color jittering, random crop, masking) to expose the student to diverse views.
  • Multi-View Adversarial Discriminator: This discriminator tries to distinguish between the teacher's features and the student's transformed features. The student is trained to "fool" this discriminator, making its features more robust and stable.

The overall framework integrates these components for end-to-end training. During inference, only the student network (and its learned projections) is used.

Datasets

The proposed method was evaluated on the following datasets:

  • CIFAR-100: A standard benchmark for image classification, used for evaluating performance on smaller-scale datasets.
  • ImageNet: A large-scale dataset for image classification, used to verify generalization and effectiveness.
  • COCO: Used for evaluating performance on object detection and instance segmentation tasks.
  • CelebA-Spoof: Used for face anti-spoofing, a binary classification task.

Key Insights and Ideas

  • Architectural Mismatch is a Major Hurdle: The paper clearly demonstrates that standard KD methods struggle with cross-architecture transfer due to fundamental differences in how CNNs and Transformers process information.
  • Projectors are Key to Alignment: The PCA and GL projectors are crucial for creating shared feature spaces where knowledge can be effectively transferred, significantly improving "knowledge transferability."
  • Global Context from Transformers is Valuable for CNNs: Distilling global relational information from Transformers provides a substantial performance boost to CNN students, enabling them to learn beyond local features.
  • Robustness is Essential for Cross-Architecture KD: The multi-view training scheme is vital for stabilizing the learning process and ensuring the student model is not overly sensitive to the teacher's specific representations.
  • CNNs Remain Relevant for Deployment: By enabling high-performance Transformers to guide CNNs, this work offers a path to deploy powerful AI capabilities on resource-constrained devices.

Key Results

The proposed method achieved state-of-the-art results across various benchmarks:

  • CIFAR-100: The cross-architecture Transformer-CNN approach showed a significant performance gain (an average of 2.7%) compared to CNN-CNN distillation.
  • ImageNet: The method consistently outperformed 14 other state-of-the-art KD methods. Notably, some distilled CNNs even surpassed Transformers with similar computational costs. For example, a ResNet50x2 student guided by a Transformer achieved over 1.03% higher accuracy than a ViT-B/32 teacher.
  • Other Tasks: The method also demonstrated strong performance on object detection, instance segmentation (COCO), and face anti-spoofing (CelebA-Spoof), indicating good generalization beyond classification.

Limitations and Future Work

  • Computational Cost of Projectors: While the GL projector uses a group-wise approach to reduce computation, the projectors themselves add some overhead during training.
  • Generalization to Other Architectures: The paper focuses on Transformer-to-CNN distillation. While it shows promise for other tasks, further exploration of different cross-architecture pairings might be beneficial.
  • Future Work: The authors suggest that their framework could be extended to bi-directional distillation (CNN to Transformer) and that the proposed method's effectiveness on edge devices could be further investigated. The ability to leverage Transformer's global reasoning for CNNs also opens avenues for more efficient and powerful CNN architectures.

Summary updated

BibTeX
@article{liu2022cross,
  author = {Yufan Liu and Jiajiong Cao and Bing Li and Weiming Hu and Jingting Ding and Liang Li and Stephen J. Maybank},
  title = {{Cross-Architecture Knowledge Distillation}},
  journal = {Int. J. Comput. Vis.},
  year = {2022},
  url = {https://openreview.net/forum?id=5opsMLx5LC},
}
Figure