Learning to Generalize: Meta-Learning for Domain Generalization

Da Li, Yongxin Yang, Yi-Zhe Song, Timothy M. Hospedales

Abstract

Domain shift refers to the well known problem that a model trained in one source domain performs poorly when applied to a target domain with different statistics. Domain Generalization (DG) techniques attempt to alleviate this issue by producing models which by design generalize well to novel testing domains. We propose a novel meta-learning method for domain generalization. Rather than designing a specific model that is robust to domain shift as in most previous DG work, we propose a model agnostic training procedure for DG. Our algorithm simulates train/test domain shift during training by synthesizing virtual testing domains within each mini-batch. The meta-optimization objective requires that steps to improve training domain performance should also improve testing domain performance. This meta-learning procedure trains models with good generalization ability to novel domains. We evaluate our method and achieve state of the art results on a recent cross-domain image classification benchmark, as well demonstrating its potential on two classic reinforcement learning tasks.

Introduction

Machine learning models are notoriously brittle; a vision system trained on high-quality photos often fails when deployed on sketches or low-light images. This phenomenon is known as domain shift. While Domain Adaptation (DA) attempts to mitigate this by using data from the target environment to fine-tune a model, Domain Generalization (DG) is a significantly harder challenge. In DG, the model has zero access to the target domain during training and must work "out of the box."

Previous DG methods often relied on complex, specialized architectures designed to extract "domain-invariant" features. This paper argues that instead of building a specific model for DG, we should change the training algorithm itself. The proposed Meta-Learning Domain Generalization (MLDG) is a model-agnostic training procedure that prepares models for unseen environments by simulating domain shift during training.

Methodology: The MLDG Algorithm

MLDG adopts a meta-learning approach, often described as "learning to learn." In this context, the model learns how to update its parameters so that those updates generalize across different data distributions.

The MLDG training procedure: source domains are split into meta-train and meta-test sets to simulate domain shift.

The algorithm follows a four-step process in each training iteration:

  1. Virtual Split: Available source domains are split into two groups: meta-train and meta-test.
  2. Meta-Train Step: The model calculates a gradient based on the meta-train domains.
  3. Meta-Test Step: The model simulates an update using that gradient and evaluates its performance on the meta-test domains (the "virtual" unseen domains).
  4. Meta-Optimization: The final update to the model's weights minimizes loss on the training domains while ensuring that the direction taken to improve training performance also improves performance on the virtual testing domains.

Mathematically, this aligns the gradients of different domains, forcing the model to find coordinated paths toward a solution that satisfy multiple environments simultaneously.

Experimental Evaluation

The authors evaluated MLDG across three distinct types of problems: synthetic classification, cross-domain image classification, and reinforcement learning.

Synthetic Binary Classification

To visualize how MLDG avoids overfitting, the authors used a toy problem with nine domains featuring different curved decision boundaries. This setup tests the model's ability to find a robust boundary that generalizes across varying distributions.

Visualization of the nine synthetic domains used to evaluate the model's ability to handle diverse decision boundaries.

PACS Benchmark and Reinforcement Learning

On the PACS Dataset (Photo, Art painting, Cartoon, Sketch), MLDG achieved a state-of-the-art average accuracy of 70.01%, outperforming the standard "Deep-All" baseline of 67.24%.

In Reinforcement Learning (RL) tasks like Cart-Pole, MLDG helped agents handle physical changes in their environment (like varying pole lengths) without retraining. When tested on unseen pole lengths, MLDG achieved a reward of 165.34, while the standard baseline collapsed to 97.39.

Key Insights and Discussion

  • Model Agnosticism: MLDG is a wrapper around the optimization process and is compatible with any differentiable model, including deep CNNs and RL policies.
  • Gradient Alignment: Through Taylor expansion analysis, the authors show that MLDG effectively maximizes the dot product between gradients of different domains, finding a "middle path" that satisfies multiple environments.
  • Scalability: Unlike many DG methods that add parameters for every new source domain, MLDG’s parameter count remains constant, making it memory-efficient for large-scale problems.

Limitations and Future Work

MLDG involves a "look-ahead" step that requires computing second-order derivatives (Hessians), making it more computationally demanding than standard SGD. Additionally, its effectiveness depends on having enough diverse source domains to simulate meaningful shifts. Future work may explore first-order approximations to reduce cost and methods to handle hyperparameter sensitivity regarding the meta-learning rate.

Summary updated

BibTeX
@inproceedings{li2018learning,
  author = {Da Li and Yongxin Yang and Yi-Zhe Song and Timothy M. Hospedales},
  title = {{Learning to Generalize: Meta-Learning for Domain Generalization}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.11596},
}
Figure