Knowledge Distillation with Feature Maps for Image Classification

Wei-Chun Chen, Chia-Che Chang, Chien-Yu Lu, Che-Rung LeearXiv 2018

TL;DR

KDFM (Knowledge Distillation with Feature Maps) is a novel model compression framework that trains compact student networks by forcing them to mimic the high-level feature maps of large teacher networks. By combining a shared classifier with a Generative Adversarial Network (GAN), KDFM produces shallow, hardware-friendly student models that achieve up to a 6x inference speedup with less than a 1% drop in accuracy compared to complex architectures like DenseNet.

What Problem Does This Paper Address?

Deep learning models have achieved remarkable success in image classification, but state-of-the-art architectures are notoriously resource-heavy. Models like VGGNet or DenseNet require millions of parameters and billions of floating-point operations (GFLOPs), making them difficult to deploy on resource-constrained platforms like mobile phones or Internet of Things (IoT) devices.

To solve this, researchers use Knowledge Distillation (KD), where a small "student" network learns to mimic a large "teacher" network. However, traditional KD approaches primarily focus on matching logits (the final output vectors before the softmax layer). The authors argue that logit-matching discards rich, high-level structural and spatial information. This limitation becomes apparent when trying to distill complex architectures like DenseNet, where standard KD student models fail to achieve comparable accuracy.

Methods

The authors propose KDFM, which shifts the focus from distilling final logits to distilling the feature maps of the teacher's final convolutional layer. These feature maps contain the most informative, high-level abstractions of an image before classification.

To effectively transfer this knowledge, KDFM introduces an architecture consisting of three components:

  1. The Generator ($G$): This is the student network's feature extractor. Its goal is to take an input image and generate feature maps that look identical to the teacher's.
  2. The Discriminator ($D$): Borrowed from GAN literature (specifically Least Squares GAN, or LSGAN), the discriminator's job is to distinguish between "real" feature maps (from the teacher) and "fake" feature maps (from the student). This adversarial training forces the student to produce high-fidelity feature maps.
  3. The Classifier ($C$): A feature decoder shared between both the teacher and the student during training. It processes the feature maps to output both "hard targets" (predicted classes) and "soft targets" (softened probability distributions).

By forcing the student and teacher to share the same classifier, the student is compelled to format its feature maps in a way that the teacher's classifier can seamlessly understand.

Fig. 1. Overview of KDFM, consisting of three module, a discriminator D, a generator G, and a classifier C. G and C compose a student network. The student network outputs the hard target for the inference.

Unlike previous methods like FitNet—which favor thin, deep student networks—KDFM intentionally designs student networks to be shallow and fat (fewer layers, more channels). This design choice is highly deliberate: shallow networks are significantly easier to parallelize on modern hardware accelerators like GPUs and TPUs, leading to faster real-world inference.

Datasets

The KDFM framework was evaluated on two benchmark image classification datasets:

  • CIFAR-100: Used to test distillation from DenseNet-40 and DenseNet-100 teachers.
  • ImageNet: Used for large-scale evaluation, featuring a MobileNet v2 student mimicking a pre-trained ResNet-152 teacher.

Key Insights and Ideas

  • Feature Maps > Logits: For complex architectures like DenseNet, final logits don't carry enough information to guide a simple student network. Distilling the final layer's feature maps preserves essential high-level semantic information.
  • The Power of a Shared Classifier: Forcing the student to use the teacher's classifier acts as a strong alignment constraint, ensuring that the student's internal representations are directly compatible with the teacher's decision-making logic.
  • Teacher Labels as Hard Targets: During distillation, the authors found that using the teacher's predicted labels as the "ground truth" (hard target) yielded better student accuracy than using the dataset's actual original labels.
  • Shallow and Fat is Faster: Increasing parameter count while keeping layer depth low creates models that run much faster on modern hardware compared to deep, narrow alternatives with the same parameter count.

Key Results

KDFM consistently outperformed baseline training and traditional logit-based knowledge distillation across multiple configurations.

Distilling DenseNet-40 (CIFAR-100)

When distilling a DenseNet-40 teacher, an 8-layer CNN student trained with KDFM achieved 74.10% accuracy, nearly matching the teacher's 74.23% and significantly outperforming standard KD and Logits Mimic Learning.

Comparison of testing accuracy across different distillation methods for an 8-layer CNN student.

Furthermore, the authors experimented with the number of convolutional layers in the student. A 4-layer CNN student actually managed to outperform the teacher network in accuracy while cutting inference time in half.

Impact of student network layer depth on accuracy and inference time.

Distilling DenseNet-100 (CIFAR-100)

Using MobileNet as a student to mimic DenseNet-100 yielded the most dramatic efficiency gains:

  • Accuracy: MobileNet (KDFM) achieved 77.20% (very close to the teacher's 77.94%).
  • Model Size: Reduced by more than half (3.5M parameters vs. 7.2M parameters).
  • Inference Speed: 6 times faster than the teacher model (2.79ms vs. 18.02ms).

ImageNet Scale

On the massive ImageNet dataset, a MobileNet v2 student mimicking ResNet-152 via KDFM achieved 71.82% accuracy, outperforming standard KD (70.16%) and the baseline MobileNet v2 trained from scratch (68.01%).

Limitations and Future Work

While KDFM shows impressive performance, the authors note a few areas for improvement:

  • Architecture Selection: The paper does not provide an automated way to design the optimal student network for a given teacher; finding the right balance of layers and channels still requires manual experimentation.
  • Hardware-Aware Objectives: The current loss function focuses purely on adversarial and distillation accuracy. The authors suggest that future iterations could directly incorporate hardware metrics—such as power consumption, memory footprint, or device-specific latency constraints—directly into the student model's optimization loop.

Summary updated

BibTeX
@misc{chen2018knowledge,
  author = {Wei-Chun Chen and Chia-Che Chang and Chien-Yu Lu and Che-Rung Lee},
  title = {{Knowledge Distillation with Feature Maps for Image Classification}},
  year = {2018},
  eprint = {1812.00660},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1812.00660},
}

Loading related content...

Figure