Domain Generalization via Model-Agnostic Learning of Semantic Features

Qi Dou, Daniel Coelho de Castro, Konstantinos Kamnitsas, Ben Glocker

Overview

Domain Generalization (DG) aims to train machine learning models that can perform well on unseen data distributions without ever being exposed to the target data during training. This paper introduces MASF (Model-Agnostic Learning of Semantic Features), a novel approach that uses a meta-learning framework to simulate domain shifts while explicitly regularizing the feature space to preserve global class relationships and local cluster compactness.

The Challenge of Domain Generalization

Most machine learning models operate under the assumption that training and testing data are drawn from the same distribution. In real-world deployments, this is rarely the case. A model trained on high-quality professional photos might fail drastically when presented with hand-drawn sketches, or a medical AI trained at one hospital might underperform at another due to variations in imaging equipment.

While Domain Adaptation attempts to solve this by utilizing a few samples from the target domain during training, Domain Generalization tackles a much harder problem: the model must generalize to a completely unknown, "black box" domain. The core challenge is teaching the model to extract robust "semantic features" (e.g., the defining characteristics of a 'dog') while ignoring "domain-specific noise" (e.g., lighting, textures, or sensor bias).

The MASF Framework

The authors propose MASF, a framework that combines two powerful concepts to tackle DG:

1. Episodic Meta-Learning

Inspired by Model-Agnostic Meta-Learning (MAML), the training process explicitly simulates domain shift. In each training iteration, the available source domains are split into "meta-train" and "meta-test" sets. The model is updated on the meta-train set and then evaluated on the meta-test set to measure how well that specific update helped it generalize across domains.

2. Semantic Feature Regularization

To guide the meta-learning process, the authors introduce two novel loss functions designed to regularize the structure of the feature space:

MASF Framework illustrating global class alignment and local sample clustering
  • Global Class Alignment ($L_{global}$): This loss ensures that the relationships between different classes remain consistent across domains. For instance, a "dog" should always be closer in feature space to a "horse" than to a "house," regardless of whether the image is a photo or a sketch. This is achieved by aligning "soft confusion matrices" (distributions of class-specific mean features) across domains using KL divergence.
  • Local Sample Clustering ($L_{local}$): This utilizes a metric-learning approach (specifically a triplet loss) to ensure that features of the same class are pulled together, while features of different classes are pushed apart. Instead of applying this directly to the main feature extractor, MASF uses a separate embedding network ($M_\phi$). This acts as a buffer, allowing the model to organize its features locally without over-constraining the primary classification task.

Key Insights and Results

The researchers evaluated MASF on three distinct benchmarks: VLCS (photos from various datasets), PACS (a challenging dataset with extreme stylistic shifts like Art, Cartoons, Photos, and Sketches), and a real-world Multi-site Brain MRI tissue segmentation task.

t-SNE visualization of the feature space showing improved clustering with MASF

MASF achieved state-of-the-art results across these benchmarks:

  • PACS Dataset: MASF reached an average accuracy of 75.21%, a significant improvement over the "DeepAll" baseline (71.70%). Notably, it boosted performance on the notoriously difficult "Sketch" domain by over 6%.
  • VLCS Dataset: The model achieved 74.11% average accuracy, outperforming previous meta-learning approaches like MLDG.
  • Medical Imaging: In the brain MRI task, MASF demonstrated consistent improvements in Dice scores (measuring segmentation overlap) across all clinical sites, proving particularly effective for the site with the poorest imaging quality.

The results highlight that simply minimizing classification error during the meta-test phase is insufficient for robust generalization. By explicitly regularizing the structure of the feature space—preserving both the "general knowledge" embedded in class confusion and the local compactness of clusters—the model learns highly transferable representations.

Limitations and Future Work

While MASF offers a robust solution for domain generalization, the authors note a few limitations. Like many meta-learning methods, computing second-order gradients introduces computational overhead, though the authors note the training time remains manageable. Additionally, the method relies on several hyperparameters (weighting coefficients and temperature parameters) that may require careful tuning for new tasks. Future work may explore expanding this semantic guidance to low-dimensional representations in generative models, which frequently struggle with domain consistency.

Summary updated

BibTeX
@inproceedings{dou2019domain,
  author = {Qi Dou and Daniel Coelho de Castro and Konstantinos Kamnitsas and Ben Glocker},
  title = {{Domain Generalization via Model-Agnostic Learning of Semantic Features}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=0vLhEGe4DuW},
}
Figure