Masked Generative Distillation

Zhendong Yang, Zhe Li, Mingqi Shao, Dachuan Shi, Zehuan Yuan, Chun Yuan

Abstract

Knowledge distillation has been applied to various tasks successfully. The current distillation algorithm usually improves students’ performance by imitating the output of the teacher. This paper shows that teachers can also improve students’ representation power by guiding students’ feature recovery. From this point of view, we propose Masked Generative Distillation (MGD), which is simple: we mask random pixels of the student’s feature and force it to generate the teacher’s full feature through a simple block. MGD is a truly general feature-based distillation method, which can be utilized on various tasks, including image classification, object detection, semantic segmentation and instance segmentation. We experiment on different models with extensive datasets and the results show that all the students achieve excellent improvements. Notably, we boost ResNet-18 from 69.90% to 71.69% ImageNet top-1 accuracy, RetinaNet with ResNet-50 backbone from 37.4 to 41.0 Boundingbox mAP, SOLO based on ResNet-50 from 33.1 to 36.2 Mask mAP and DeepLabV3 based on ResNet-18 from 73.20 to 76.02 mIoU.

Introduction

Knowledge Distillation (KD) typically involves a "teacher" model transferring its learned expertise to a smaller "student" model. Traditional feature-based KD methods rely on direct imitation, forcing the student to replicate the teacher's intermediate representations. However, because deep features are inherently redundant, strict mimicry may not be the most efficient way to transfer knowledge. We propose that students can develop stronger representation power by learning to recover missing information, a concept we formalize as Masked Generative Distillation (MGD).

Methodology: Masked Generative Distillation

MGD shifts the distillation paradigm from imitation to generation. Instead of direct alignment, the student is tasked with reconstructing the teacher's full feature map from a partially masked version of its own features.

The MGD framework: Student features are masked and then passed through a generation block to reconstruct the teacher's full features.

The process involves three key components:

  1. Random Masking: A random mask is applied to the student's feature map (from the backbone or neck), zeroing out a portion of the spatial pixels or channels.
  2. Generation Block: The masked features are processed by a simple block consisting of two $3 \times 3$ convolutional layers and a ReLU activation.
  3. Distillation Loss: The student is trained to minimize the $L_2$ distance between its generated output and the teacher's original, unmasked feature map.

By forcing the student to "fill in the blanks," MGD encourages the model to capture more robust contextual relationships within the data.

Key Insights and Results

MGD demonstrates superior performance across a wide range of computer vision tasks, including classification (ImageNet), detection (COCO), and segmentation (CityScapes).

Visualization of feature attention maps for different distillation methods on an object detection task. MGD helps the student focus more accurately on the object of interest while suppressing background noise.

Generative Recovery vs. Direct Mimicry

A core finding is that the student does not need to be a "clone" of the teacher. Visualizations reveal that MGD-trained students often develop features that differ significantly from the teacher's in appearance but surpass them in task-specific utility. As shown in the attention maps, MGD is particularly effective at suppressing background noise, allowing the student to focus more intensely on the primary objects of interest compared to baseline students or those trained with imitation-based methods like FGD.

Performance Gains

  • Object Detection: On COCO, MGD improved RetinaNet (ResNet-50) from 37.4 to 41.0 mAP, matching the teacher's performance.
  • Image Classification: ResNet-18 on ImageNet saw a boost from 69.90% to 71.69% top-1 accuracy.
  • Segmentation: Significant improvements were noted in both instance segmentation (SOLO) and semantic segmentation (DeepLabV3).

Conclusion and Limitations

Masked Generative Distillation provides a simple, task-agnostic framework for feature-based distillation. By treating knowledge transfer as a reconstruction task, it significantly enhances the student's representation power. While highly effective, MGD's performance can be sensitive to the mask ratio and is most potent when teacher and student share similar architectural lineages. Future work may explore more complex masking strategies or adaptive generation blocks to further refine the distillation process.

Summary updated

BibTeX
@inproceedings{yang2022masked,
  author = {Zhendong Yang and Zhe Li and Mingqi Shao and Dachuan Shi and Zehuan Yuan and Chun Yuan},
  title = {{Masked Generative Distillation}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  url = {https://openreview.net/forum?id=DjRAwj5VE2},
}
Figure