Representation Transfer by Optimal Transport

Xuhong Li, Yves Grandvalet, Rémi Flamary, Nicolas Courty, Dejing DouarXiv 2020

Abstract

Learning generic representations with deep networks requires massive training samples and significant computer resources. To learn a new specific task, an important issue is to transfer the generic teacher's representation to a student network. In this paper, we propose to use a metric between representations that is based on a functional view of neurons. We use optimal transport to quantify the match between two representations, yielding a distance that embeds some invariances inherent to the representation of deep networks. This distance defines a regularizer promoting the similarity of the student's representation with that of the teacher. Our approach can be used in any learning context where representation transfer is applicable. We experiment here on two standard settings: inductive transfer learning, where the teacher's representation is transferred to a student network of same architecture for a new related task, and knowledge distillation, where the teacher's representation is transferred to a student of simpler architecture for the same task (model compression). Our approach also lends itself to solving new learning problems; we demonstrate this by showing how to directly transfer the teacher's representation to a simpler architecture student for a new related task.

Introduction

The computational cost and data requirements of training deep neural networks from scratch have made representation transfer a cornerstone of modern machine learning. Typically, a "student" network inherits knowledge from a pre-trained "teacher" through fine-tuning. However, standard techniques like parameter-based regularization (e.g., $L^2$-SP) suffer from a fundamental limitation: they are "blind" to the permutation invariance of neural networks. Because neurons in a layer can be reordered without changing the network's output, forcing a strict one-to-one weight mapping is often suboptimal. Furthermore, these methods cannot easily bridge networks with different architectures.

This paper introduces a novel framework that leverages Optimal Transport (OT) to align internal representations. By focusing on the functional behavior of neurons—how they respond to data—rather than their static weights, this approach enables flexible, permutation-invariant knowledge transfer across diverse architectures.

Methodology: Aligning Functional Representations

The proposed method treats neurons as functions mapping inputs to activations. The goal is to minimize the distance between the set of features produced by the student and those produced by the teacher.

Overview of the proposed representation transfer framework. The student network is regularized by an Optimal Transport cost $\Omega_P$ that aligns its activations with those of a frozen teacher.

The Optimal Transport Regularizer

For a given mini-batch of data, the method computes a cost matrix $M$, where each entry $M_{ij}$ represents the Euclidean distance between the activations of the $i$-th student neuron and the $j$-th teacher neuron. The transfer problem is then formulated as finding an optimal coupling (transport plan) $P$ that minimizes the total transport cost.

This formulation offers several key advantages:

  1. Permutation Invariance: The OT cost is independent of the order of neurons, allowing the student to reorganize its internal logic dynamically.
  2. Architecture Agnosticism: Because the method compares activation vectors, it naturally handles cases where the student and teacher have different numbers of neurons.
  3. Dynamic Alignment: The transport plan is updated at every iteration using the Inexact Proximal Optimal Transport (IPOT) algorithm, a stabilized version of the Sinkhorn algorithm.

To maintain training efficiency, the authors employ the Envelope Theorem, which allows them to compute gradients by treating the transport plan as fixed during the backpropagation step.

Experimental Evaluation

The authors evaluated the OT-based regularizer ($\Omega_P$) across three primary settings: inductive transfer learning, model compression (knowledge distillation), and a hybrid "one-step" transfer and compression task.

Inductive Transfer Learning

In this setting, a teacher pre-trained on ImageNet transfers its representation to a student of the same architecture for a new, specialized task. The method was tested on five datasets: Aircraft100, Birds200, Cars196, Dogs120, and Foods101.

Performance comparison of the OT regularizer ($\Omega_P$) against standard fine-tuning (none) and various regularization baselines. $\Omega_P$ consistently achieves the highest accuracy across most tasks.

As shown in the results, $\Omega_P$ consistently outperformed standard fine-tuning and $L^2$-SP. For instance, on Aircraft100, it achieved 85.19% accuracy, a significant improvement over the 83.94% achieved by $L^2$-SP.

Model Compression and Hybrid Transfer

In knowledge distillation tasks on CIFAR datasets, the OT approach surpassed classic Knowledge Distillation (KD). For a ResNet-1001 to ResNet-56-Slim transfer on CIFAR-10, OT reached 92.8% accuracy compared to KD's 92.4%.

The framework also enabled a "one-step" transfer where knowledge was moved from a complex ResNet-101 to a simpler MobileNet-V2 for a new task. This proved highly effective, particularly when the student had limited pre-training, boosting Birds200 accuracy from 71.99% to 75.17%.

Discussion and Conclusion

The use of Optimal Transport provides a powerful, unified framework for representation transfer. By respecting the inherent symmetries of neural networks, it allows for more efficient and flexible learning.

While the method introduces some computational overhead—approximately 2.7x slower than simple parameter regularization—and requires tuning the regularization strength, its performance gains and architectural flexibility are compelling. Future work may extend this functional alignment to non-classification tasks like regression or ranking, where traditional distillation methods are less applicable.

Summary updated

BibTeX
@misc{li2020representation,
  author = {Xuhong Li and Yves Grandvalet and Rémi Flamary and Nicolas Courty and Dejing Dou},
  title = {{Representation Transfer by Optimal Transport}},
  year = {2020},
  eprint = {2007.06737},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2007.06737},
}
Figure