Learning domain invariant representations by joint Wasserstein distance minimization

Léo Andéol, Yusei Kawakami, Yuichiro Wada, Takafumi Kanamori, Klaus-Robert Müller, Grégoire MontavonNeural Networks 2021 · DOI

Abstract

Domain shifts in the training data are common in practical applications of machine learning; they occur for instance when the data is coming from different sources. Ideally, a ML model should work well independently of these shifts, for example, by learning a domain-invariant representation. However, common ML losses do not give strong guarantees on how consistently the ML model performs for different domains, in particular, whether the model performs well on a domain at the expense of its performance on another domain. In this paper, we build new theoretical foundations for this problem, by contributing a set of mathematical relations between classical losses for supervised ML and the Wasserstein distance in joint space (i.e. representation and output space). We show that classification or regression losses, when combined with a GAN-type discriminator between domains, form an upper-bound to the true Wasserstein distance between domains. This implies a more invariant representation and also more stable prediction performance across domains. Theoretical results are corroborated empirically on several image datasets. Our proposed approach systematically produces the highest minimum classification accuracy across domains, and the most invariant representation.

Introduction

In real-world machine learning, data often comes from different "domains"—for example, photos of objects taken in a lab versus photos from a smartphone. Standard models often suffer from domain shift, where a model trained on one domain performs poorly on another.

While fields like Domain Adaptation (focusing on a specific target domain) and Domain Generalization (focusing on unseen domains) are well-studied, this paper focuses on Domain Invariance (DI). The goal here is to treat a finite set of known domains equally, ensuring the model's performance is well-balanced and stable across all of them. The authors identify a gap: common loss functions do not provide strong guarantees on how consistently a model will perform across these different sources.

Comparison of Domain Adaptation, Domain Invariance, and Domain Generalization. Domain invariance aims for stable performance across a finite set of known domains.

Methodology

The authors propose a method to align domains in a "joint space" (representation + output). Their approach is built on several key technical pillars:

  1. Joint Wasserstein Distance: Unlike previous methods that only align the feature distributions (marginal distributions), this work aligns the joint distribution of features and labels. This ensures that the relationship between features and classes remains consistent across domains.
  2. Theoretical Bounds: The paper contributes new mathematical proofs showing that supervised losses (like Cross-Entropy for classification or Mean Absolute Error for regression), when combined with a domain discriminator, form an upper bound to the true Wasserstein distance between domains.
  3. The Domain Critic: They implement a GAN-like optimization problem. A "feature extractor" tries to make domains indistinguishable, while a "domain critic" tries to tell them apart. They use a Gradient Reversal Layer (GRL) to train these components simultaneously.
  4. Semi-Supervised Handling: The framework is designed to work even when only a fraction of the data is labeled. They use the model's own predictions to "impute" missing labels, allowing the domain alignment to benefit from large amounts of unlabeled data.
The proposed framework maps input space to a representation space where domains are aligned, followed by classification.

Experimental Results

The authors corroborated their theory using three major benchmarks: MNIST vs. SVHN, Office-Caltech, and PACS.

Key insights from the empirical evaluation include:

  • Higher Minimum Accuracy: In experiments on MNIST/SVHN and Office-Caltech, the proposed "Joint Critic" consistently produced the highest minimum accuracy across domains compared to baselines that used no critic or only a marginal critic. This confirms the theoretical goal of balanced performance.
  • Visual Alignment: UMAP visualizations clearly show that under the proposed training, the separate clusters of different domains merge into a single, unified distribution in the representation space.
  • Performance Gap Guarantee: Theorem 2 shows that the Wasserstein distance between domains directly bounds the difference in error rates between those domains. Shrinking this distance forces the model to be equally accurate on all domains.
  • Domain-Specific Features for Invariance: Using Layer-wise Relevance Propagation, the authors found that to reach an invariant representation, the model actually recognizes domain-specific features (like color or style) and then uses that information to map the data into a shared, domain-agnostic space.

Conclusion and Future Work

This work provides a robust theoretical foundation for learning domain-invariant representations by minimizing the joint Wasserstein distance. While the method shows superior stability and minimum accuracy, some limitations remain. For instance, the Wasserstein distance can "artificially" go to zero if the representation scale is not properly constrained. The authors addressed this with specific penalties, but it remains a point of attention for implementation.

Future directions include extending this theory to Domain Generalization (unseen domains) and exploring connections to Contrastive Learning, which also relies on learning invariant features to improve robustness and generalization.

Summary updated

BibTeX
@inproceedings{andeol2021learning,
  author = {Léo Andéol and Yusei Kawakami and Yuichiro Wada and Takafumi Kanamori and Klaus-Robert Müller and Grégoire Montavon},
  title = {{Learning domain invariant representations by joint Wasserstein distance minimization}},
  booktitle = {Neural Networks},
  year = {2021},
  doi = {10.1016/j.neunet.2023.07.028},
}
Figure