Temporal Test-Time Adaptation with State-Space Models

Mona Schirmer, Dan Zhang, Eric Nalisnick · Submission to ICLR 2025 · Rejected

Introduction

Machine learning models often have an "expiration date" because the real world they operate in changes over time. This paper introduces STAD (State-space Test-time Adaptation), a method that uses Bayesian filtering to track how data distributions drift. This approach allows deployed models to update themselves on the fly without needing new labels or access to the original training data.

The Challenge of Temporal Shift

Most machine learning models are trained on a static snapshot of data. However, once deployed, they inevitably face "distribution shift"—the incoming test data begins to look different from the training data. While Test-Time Adaptation (TTA) aims to fix this by updating the model using only incoming test batches, most existing methods focus on synthetic, static corruptions (like adding digital "noise" or "blur" to images).

In reality, distribution shifts are often temporal and structural. For example, fashion trends change over decades in portrait photos, and rural land gradually turns into urban sprawl in satellite imagery. Existing TTA methods often "collapse" when faced with these gradual shifts, especially when test batches are very small or when the frequency of different classes changes (label shift). The authors identify a critical gap: we need TTA methods that explicitly model the dynamics of how data evolves over time.

STAD: Tracking Data Dynamics

The authors propose STAD, which treats the adaptation process as a tracking problem. Instead of updating the entire neural network—which is computationally expensive and prone to "forgetting" past knowledge—STAD only adapts the very last layer, the classification head.

Tracking class prototypes over time

Key technical components of this approach include:

  • State-Space Models (SSMs): STAD uses linear SSMs (similar to Kalman filters) to model the movement of "class prototypes" (the average feature vector for each class) in the model's representation space.
  • Unsupervised Bayesian Filtering: Since there are no labels available at test time, STAD uses an Expectation-Maximization (EM) algorithm to infer which class a sample likely belongs to, and then updates the corresponding class prototype accordingly.
  • Two Geometric Variants:
    • STAD-Gauss: Uses standard Gaussian distributions, operating in Euclidean geometry.
  • STAD-vMF: Uses the von Mises-Fisher distribution, which models data on a hypersphere. This is particularly effective because neural network features are often more distinguishable by their angle than their magnitude under distribution shift.
  • Sliding Window: To maintain computational efficiency, the model only looks at a small window of recent history to update its parameters.

Datasets and Evaluation

The researchers evaluated STAD on a mix of "in-the-wild" temporal datasets and standard benchmarks:

  • Yearbook: Portraits of American high school students from 1930 to 2013, capturing shifts in hairstyles, clothing, and demographics.
  • EVIS (Evolving Image Search): Images of vehicles and electronics from 2009 to 2020, capturing rapid technological design changes.
  • FMoW-Time (Functional Map of the World): Satellite images mapping land use over 15 years.
  • Standard Benchmarks: CIFAR-10.1, ImageNetV2 (reproduction datasets), and CIFAR-10-C (synthetic corruptions).

Key Insights

  • Dynamics are Crucial: The most significant finding is that explicitly modeling how the distribution moves (the transition model) is vital. Removing the temporal dynamics from STAD caused performance to drop by up to 28 percentage points.
  • The "Less is More" Philosophy: By only adapting the final layer, STAD avoids the instability and "parameter collapse" that often plagues methods trying to update the entire feature extractor via gradient descent.
  • Robustness to Small Batches: Most TTA methods require large batches of data to calculate reliable statistics. Because STAD uses Bayesian filtering, it remains stable even with a batch size of 1, making it highly practical for real-time streaming applications.
  • Geometry Matters: The hyperspherical (vMF) version frequently outperformed the Gaussian version, confirming that angular distances provide a more robust signal for class membership when data drifts.

Key Results

STAD demonstrates significant improvements over existing baselines, particularly in complex real-world scenarios.

Performance comparison on temporal datasets
  • Superior Temporal Adaptation: On the FMoW satellite dataset, STAD improved accuracy by over 17 points compared to the unadapted source model, significantly outperforming popular baselines like TENT and CoTTA.
  • Handling Label Shift: STAD excels when the "mix" of classes changes over time. In scenarios with extreme label shift, it consistently ranked as the best or second-best model across all datasets.
  • Efficiency: STAD-vMF scales linearly with feature dimensions, making it much faster and more memory-efficient than Gaussian-based tracking methods, which scale cubically.
  • Unsupervised Monitoring: The authors found that "cluster dispersion" (how spread out the prototypes are) correlates with accuracy, suggesting it could be used as a built-in metric to flag when a model is starting to fail.

Limitations and Future Work

While powerful, STAD has limitations. Because it only adapts the final layer, it is less effective when the distribution shift primarily affects early layers of the network (e.g., heavy pixel-level noise). In those cases, adapting the feature extractor is still necessary. Additionally, the model assumes that class prototypes move smoothly; a sudden, "catastrophic" shift might break the temporal correlation STAD relies on.

Future directions include incorporating actual timestamps into the model to better handle irregularly sampled data, and exploring ways to combine STAD with feature-extractor adaptation for even greater robustness.

Summary updated

BibTeX
@misc{schirmer2024temporal,
  author = {Mona Schirmer and Dan Zhang and Eric Nalisnick},
  title = {{Temporal Test-Time Adaptation with State-Space Models}},
  year = {2024},
  eprint = {2407.12492},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.12492},
}
Figure