Gated Domain Units for Multi-source Domain Generalization

Simon Föll, Alina Dubatovka, Eugen Ernst, Siu Lun Chau, Martin Maritsch, Patrik Okanovic, Gudrun Thäter, Joachim M. Buhmann, Felix Wortmann, Krikamol Muandet

TL;DR

This paper introduces Gated Domain Units (GDUs), a novel neural network layer designed to tackle distribution shift without requiring explicit domain labels. By modeling complex data distributions as mixtures of latent "Invariant Elementary Distributions," GDUs dynamically weight an ensemble of sub-models at inference time, delivering robust out-of-distribution generalization across image, text, and graph datasets.

What Problem Does This Paper Address?

Standard machine learning models rely on the fundamental assumption that training and test data are independently and identically distributed (I.I.D.). In real-world deployments, however, this assumption frequently breaks down due to distribution shift. For instance, a medical imaging model trained on data from a specific set of hospitals might degrade significantly when deployed at a new hospital due to variations in patient demographics, slide staining techniques, or imaging equipment.

Figure 1: An illustration of invariant elementary distributions in camelyton17 dataset and the concept of the Gated Domain Units (GDUs). While data sources are often considered as domains, each hospital contains heterogene subsets that are shared across sources. We can depict examples of these subsets (latent domains) in three different shapes (rectangle, octahedron, and circle) for each domain following the method of Matsuura & Harada (2020). In contrast to existing work, the invariant elementary distribution (I.E.D.) assumption advocates that these latent domains remain invariant across the hospitals. Therefore, we propose to learn representations of these elementary domains akin to mixture models, and utilise our Gated Domain Units to build a weighted ensemble during inference time.

Domain Generalization (DG) fields algorithms to mitigate this issue by learning representations that transfer well to unseen target domains. However, existing approaches suffer from two major limitations:

  1. They often require explicit, clean domain labels during training, which can be ambiguous, expensive, or impossible to acquire.
  2. They typically assume that an unseen test domain is a simple convex combination of the training domains, which limits flexibility.

This paper introduces a framework that generalizes to completely unseen domains by uncovering hidden, invariant structures without relying on explicit domain annotations.

Methods

The authors propose the Invariant Elementary Distribution (I.E.D.) assumption: rather than treating domains as monolithic blocks, they postulate that all domains (both seen and unseen) are unique mixtures of underlying, unobserved "elementary" distributions that remain constant across environments.

To operationalize this theory, they introduce Gated Domain Units (GDUs) as a modular neural network layer:

  • Kernel Mean Embedding (KME): Since the true latent elementary distributions are unknown, GDUs use KMEs to map data into a Reproducing Kernel Hilbert Space (RKHS). This provides a clean geometric representation of the latent distributions using learned "domain bases" ($V_j$) stored directly as layer weight matrices.
  • Dynamic Gating and Ensembling: During inference, when a new sample is processed, the GDU layer computes its similarity to each learned domain basis. The layer supports both geometry-based similarities (e.g., Cosine Similarity, Maximum Mean Discrepancy) and projection-based similarities. These similarity scores act as dynamic gating weights to combine predictions from an ensemble of domain-specific sub-models.
  • Orthogonality & Sparsity Regularization: To ensure high expressive power and prevent the learned bases from collapsing into identical representations, the authors introduce specialized loss terms, including an ordinary least squares (OLS) reconstruction loss and soft orthogonality constraints tracked via the Spectral Restricted Isometry Property (SRIP).
Figure 3: Visualization of the layer (upper panel) and its main component, the GDU (lower panel). The layer consists of multiple GDUs that represent the elementary distributions. During training, the GDUs learn the elementary domain basis V1, . . . , VM that approximate these distributions.

Datasets

The framework was rigorously evaluated across multiple data modalities using both synthetic and real-world benchmarks:

  • Digits Classification: A multi-source dataset combining five distinct digits databases: MNIST, MNIST-M, SVHN, USPS, and Synthetic Digits (SYN).
  • WILDS Benchmark: A standard, real-world distribution shift benchmark consisting of:
  • Images: Camelyon17 (tumor identification in tissue slides), iWildCam (wildlife camera traps), RxRx1 (genetic cellular treatments).
  • Satellite Imagery: FMoW (functional map of the world land-use), PovertyMap (asset wealth prediction).
  • Text: Amazon (sentiment classification), CivilComments (toxicity detection across demographic subgroups).
  • Graphs: OGB-MolPCBA (molecular property prediction).

Key Insights and Ideas

  • Granular Invariance: Instead of trying to force alignment at a macro domain level (e.g., aligning entire hospitals), GDUs find invariant features at a latent, granular level. An unseen test domain doesn't need to match a training domain; it just needs to be composed of the same underlying elementary building blocks.
  • Independence from Domain Labels: Because the elementary distributions are discovered in an unsupervised manner during backpropagation, GDUs function seamlessly even when training data lacks domain annotations entirely.
  • The Pareto Connection: The authors theoretically prove that under the I.E.D. assumption, finding the optimal predictor is equivalent to solving a multi-objective optimization problem. This guarantees that the optimal model lies within a strict "Pareto-optimal" subspace, justifying their ensembling approach.

Key Results

  • Consistent Performance Gains: GDUs consistently outperformed standard Empirical Risk Minimization (ERM) across all eight WILDS datasets, regardless of whether the data was an image, text, or a graph. For example, on the PovertyMap dataset, the GDU approach achieved a Worst-case Pearson correlation of 0.62, a substantial leap over ERM's 0.45.
  • Competitive with State-of-the-Art: While some specialized algorithms (like LISA) achieved slightly higher scores on specific datasets when provided with perfect domain labels, GDUs delivered state-of-the-art performance among methods that do not use domain information.
  • Balancing the Robustness Trade-off: Many robust optimization techniques suffer from a trade-off where improving worst-case performance drastically degrades average-case performance. GDUs successfully balanced this trade-off, boosting worst-case metrics without sacrificing average accuracy.

Limitations and Future Work

  • Predefined Number of Units: The number of elementary distributions ($M$) is a hyperparameter that must be specified in advance. Although the authors provide a clustering-based heuristic using the Davies-Bouldin score to estimate $M$, dynamically adjusting this number during training remains an open challenge.
  • Computational Overhead: Operating an ensemble of sub-models and calculating kernel-based regularizations inherently increases the parameter count and computational footprint compared to a simple dense layer.
  • Future Directions: The authors suggest developing flexible architectures that can adaptively split or spawn new GDUs during training (e.g., using deterministic annealing) if the variance within a latent domain becomes too large.

Summary updated

BibTeX
@article{foll2023gated,
  author = {Simon Föll and Alina Dubatovka and Eugen Ernst and Siu Lun Chau and Martin Maritsch and Patrik Okanovic and Gudrun Thäter and Joachim M. Buhmann and Felix Wortmann and Krikamol Muandet},
  title = {{Gated Domain Units for Multi-source Domain Generalization}},
  journal = {Accepted by TMLR},
  year = {2023},
  url = {https://openreview.net/forum?id=V7BvYJyTmM},
}
Figure