Non-stationary Domain Generalization: Theory and Algorithm

Thai-Hoang Pham, Xueru Zhang, Ping Zhang

Introduction

Traditional machine learning models are typically built upon the Independent and Identically Distributed (IID) assumption, where training and testing data are expected to originate from the same distribution. Domain Generalization (DG) was developed to relax this constraint, aiming to train models on multiple "source" domains so they can generalize to an unseen "target" domain. However, standard DG approaches often treat these domains as an unordered set, assuming stationarity.

In real-world scenarios—such as satellite imagery affected by urban development or clinical data shifting with medical advancements—domains often evolve along a trajectory. In these non-stationary environments, the target domain is not merely a different distribution but the next logical step in a sequence. This paper introduces Adaptive Invariant Representation Learning (AIRL), a framework designed to leverage the sequential structure of domains to capture non-stationary patterns.

The Problem: Beyond the "Mixture" Trap

Conventional DG methods often fail in evolving environments because they attempt to find a single, static representation that remains invariant across all source domains. This assumes the target domain lies within the "mixture" or convex hull of the source distributions. In non-stationary DG, the target domain frequently lies outside this mixture, following a trend or trajectory. By ignoring the temporal or spatial ordering, standard methods discard valuable information regarding the direction of the distribution shift.

Methodology

1. Theoretical Foundation

The authors establish new theoretical upper bounds for model error in non-stationary environments. Their proof demonstrates that minimizing error on a future target domain requires minimizing the divergence between actual source distributions and the distributions "generated" or predicted by the model’s internal mechanism. This shifts the focus from finding a global invariant to understanding the dynamics of change.

2. The AIRL Algorithm

AIRL addresses non-stationarity through a two-pronged architectural approach:

  • Representation Network (Transformer-based): Rather than forcing a static feature space across all time points, AIRL utilizes a Transformer to learn how representations evolve from one domain to the next. It enforces pairwise invariance, ensuring features are consistent between consecutive domains ($D_t$ and $D_{t+1}$). This allows the model to adapt gracefully across a long sequence without losing the information necessary for the task.
  • Classification Network (LSTM-based): To account for the changing relationship between features and labels, an LSTM models the evolution of the classifier's weights. This allows the model to extrapolate the classifier parameters for a future domain without having seen any data from that domain.

Experimental Evaluation

The effectiveness of AIRL was evaluated across five diverse datasets representing both synthetic and real-world evolution:

  • Synthetic (Circle & Circle-Hard): 2D Gaussian distributions moving along a path. AIRL achieved an Out-of-Distribution (OOD) accuracy of 73.50% on Circle-Hard, significantly outperforming standard Empirical Risk Minimization (ERM) at 66.94%.
  • RMNIST: MNIST digits rotated at increasing angles (0° to 180°).
  • Yearbook: A real-world dataset of American high school yearbook photos (1930–2013). AIRL reached 93.10% accuracy, surpassing traditional domain-invariant methods that struggle with long-term fashion shifts.
  • CLEAR: A decade-long dataset (2004–2014) capturing natural temporal evolution in visual concepts.

Across these benchmarks, AIRL consistently outperformed state-of-the-art baselines, including DANN, CORAL, and specialized non-stationary methods like DRAIN and TKNets. Notably, AIRL showed marked improvement in the $OOD_{Wrt}$ metric, which measures performance in the most difficult (worst-case) target domains.

Key Insights and Future Directions

AIRL’s success stems from its rejection of global invariance in favor of pairwise, adaptive invariance. By treating the target as a continuation of a trend rather than a member of a static set, the model can anticipate future shifts.

However, several challenges remain for future research:

  1. Complexity Estimation: There is currently no robust method to estimate the "non-stationary complexity" of a sequence from finite data.
  2. Online Learning: The current AIRL framework is an offline algorithm requiring access to all source domains during training. Transitioning this to an online setting where data arrives sequentially is a logical next step.
  3. Architecture Selection: The model's performance remains sensitive to the choice of hypothesis classes for the Transformer and LSTM components relative to the specific evolution pattern of the data.

In conclusion, AIRL provides a robust theoretical and algorithmic framework for machine learning in a changing world, moving beyond static generalization toward predictive adaptation.

Summary updated

Abstract

Although recent advances in machine learning have shown its success to learn from independent and identically distributed (IID) data, it is vulnerable to out-of-distribution (OOD) data in an open world. Domain generalization (DG) deals with such an issue and it aims to learn a model from multiple source domains that can be generalized to unseen target domains. Existing studies on DG have largely focused on stationary settings with homogeneous source domains. However, in many applications, domains may evolve along a specific direction (e.g., time, space). Without accounting for such non-stationary patterns, models trained with existing methods may fail to generalize on OOD data. In this paper, we study domain generalization in non-stationary environment. We first examine the impact of environmental non-stationarity on model performance and establish the theoretical upper bounds for the model error at target domains. Then, we propose a novel algorithm based on adaptive invariant representation learning, which leverages the non-stationary pattern to train a model that attains good performance on target domains. Experiments on both synthetic and real data validate the proposed algorithm.
BibTeX
@inproceedings{pham2024non,
  author = {Thai-Hoang Pham and Xueru Zhang and Ping Zhang},
  title = {{Non-stationary Domain Generalization: Theory and Algorithm}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=AMxdbjUvWg},
}
Figure