Function-Consistent Feature Distillation

Dongyang Liu, Meina Kan, Shiguang Shan, Xilin Chen

TL;DR

Function-Consistent Feature Distillation (FCFD) moves beyond simple "appearance-based" mimicking in knowledge distillation. Instead of just minimizing the L2 distance between teacher and student features, FCFD ensures that student features produce similar results to the teacher when processed by the later layers of the network. This effectively prioritizes the "functional" importance of different feature dimensions over their raw numerical values.

What Problem Does This Paper Address?

Knowledge Distillation (KD) aims to compress large "teacher" models into compact "student" models. Most state-of-the-art methods focus on feature distillation, where the student tries to mimic the intermediate representations of the teacher.

The authors identify a fundamental flaw in existing methods: they almost exclusively use L2 distance (or variants) to measure similarity. L2 distance is isotropic, meaning it treats every dimension of a feature vector as equally important. However, neural networks are anisotropic—certain dimensions in an intermediate feature map have a much larger impact on the final output than others.

Isotropic L2 vs. Anisotropic Function

If a student mimics the "appearance" of a feature perfectly but misses a small, functionally critical detail, the final performance suffers. The challenge is to move from mimicking what a feature looks like to mimicking how a feature functions within the context of the remaining network.

Methods

The core of FCFD is the introduction of a "functional" loss that uses the later parts of the network as a "lens" to evaluate feature quality.

FCFD Architecture and Training Pipeline
  1. Appearance Loss ($L_{app}$): A standard L2 distance between teacher features and student features (transformed via a "bridge" convolution to match shapes).
  2. Teacher as Lens ($L_{func}$): Student features are fed into the teacher’s subsequent layers. The resulting outputs are compared to the teacher’s original intermediate outputs at those later stages. This forces the student to produce features that the teacher’s "brain" can interpret correctly.
  3. Student as Lens ($L_{func'}$): Conversely, teacher features are fed into the student’s subsequent layers. The final output is compared against the teacher’s soft logits. This ensures the student’s later layers learn to process high-quality features correctly.
  4. Efficiency via Random Sampling: Passing features through multiple extra forward paths is computationally expensive. To solve this, FCFD randomly samples only a few "paths" per iteration during training, significantly reducing overhead while maintaining performance.
  5. BatchNorm Handling: Since different paths (e.g., student-to-teacher vs. pure teacher) have different feature distributions, the authors accumulate BatchNorm running statistics separately for each path to prevent inference-time degradation.

Key Insights and Ideas

  • Function over Form: The "aha moment" is that intermediate features don't have a fixed meaning in isolation; their meaning is defined by how the rest of the network processes them.
  • Synergy: The authors found that appearance loss ($L_{app}$) and functional loss ($L_{func}$) are complementary. Appearance loss keeps the student in the right "neighborhood" of the feature space, while functional loss fine-tunes the student to focus on task-relevant dimensions.
  • Robustness to Architecture Mismatch: FCFD is particularly effective when the teacher and student have different architectures (e.g., a ResNet teacher and a MobileNet student). In these cases, simple numerical mimicking is often impossible or unhelpful, but functional alignment allows the student to learn the teacher's "logic" using its own structural constraints.

Key Results

The authors evaluated FCFD across several standard benchmarks, including CIFAR-100, ImageNet, and MS-COCO.

  • CIFAR-100: FCFD consistently outperformed SOTA methods like ReviewKD and DKD. For a ResNet32x4 teacher and a ShuffleV1 student, FCFD achieved 78.12% top-1 accuracy, a significant jump over the 70.50% baseline and 77.45% for ReviewKD.
  • ImageNet: On the ResNet34 to ResNet18 task, FCFD reached 72.25% top-1 accuracy, outperforming the previous best (DKD) by 0.55%.
  • Object Detection: On MS-COCO, FCFD improved the mAP of a Faster R-CNN (ResNet50) student by +2.49, outperforming specialized detection distillation methods like FGFI and ICD.
  • Compatibility: FCFD is "orthogonal" to many logit-based distillation methods. Combining FCFD with DKD or SimKD resulted in even higher accuracies, showing it can be a "plug-and-play" enhancement for existing pipelines.

Limitations and Future Work

  • Training Overhead: Even with random path sampling, FCFD requires more memory and training time than simple L2 distillation because of the extra forward passes through later layers.
  • Hyperparameter Sensitivity: The method introduces weights for the different functional paths, which might require tuning depending on the specific architecture pair.
  • Future Directions: The authors suggest exploring FCFD in non-vision tasks, such as Natural Language Processing (NLP), where the anisotropic nature of Transformers might make functional consistency even more critical.

Summary updated

BibTeX
@inproceedings{liu2023function,
  author = {Dongyang Liu and Meina Kan and Shiguang Shan and Xilin CHEN},
  title = {{Function-Consistent Feature Distillation}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=pgHNOcxEdRI},
}
Figure