Predicting Out-of-Domain Generalization with Local Manifold Smoothness

Nathan Ng, Neha Hulkund, Kyunghyun Cho, Marzyeh GhassemiarXiv 2022

Introduction

Deep learning models frequently exhibit a "generalization gap," performing exceptionally well on training data but failing when deployed in real-world scenarios. This issue is particularly acute in Out-of-Domain (OOD) settings, where test data deviates from the training distribution (e.g., classifying sketches instead of photos). Traditional methods for predicting performance often rely on internal model parameters or the assumption that test data is identically distributed to training data. This paper introduces Neighborhood Invariance (NI), a label-free, black-box metric designed to estimate OOD accuracy by measuring local decision boundary smoothness.

Methodology: Neighborhood Invariance

The core idea behind Neighborhood Invariance is that a robust model should produce consistent predictions for an input and its local variations. If a model truly understands a concept, small, label-preserving transformations—such as slight rotations or word substitutions—should not trigger a change in the predicted class.

The NI estimation process follows a simple pipeline:

  1. Sampling: Select an unlabeled test point $x$.
  2. Neighborhood Generation: Apply $N$ label-preserving transformations to $x$ to create a local neighborhood $G_r(x)$.
  3. Consistency Measurement: Pass the neighborhood through the model and calculate the fraction of points assigned to the most frequent predicted class.
  4. Aggregation: Average these scores across the entire test set to derive a global invariance measure.

Crucially, this is a Monte Carlo estimation that requires no labels. If a model is highly invariant, it suggests the model has learned a "smoother" decision boundary, which historically correlates with better generalization.

The Neighborhood Invariance (NI) pipeline for estimating OOD performance.

Key Insights: Invariance as a Proxy for Complexity

Neighborhood Invariance serves as a proxy for a model's local complexity. A model that frequently changes its prediction in response to minor input perturbations effectively has a "wiggly" or complex decision boundary. Conversely, a "smoother" boundary indicates higher invariance and typically correlates with better generalization.

Comparison of decision boundaries for less vs. more invariant classifiers.

Unlike confidence-based metrics like Average Thresholded Confidence (ATC), NI is independent of model calibration. It does not rely on the magnitude of the softmax output (which can be misleadingly high on OOD data) but rather on the stability of the prediction across the neighborhood. This makes it particularly effective for "hostile" datasets like ImageNet-A, where models are often overconfident in their errors.

Experimental Evaluation

The researchers validated NI through an extensive empirical study involving over 4,600 models across 100 unique train/test domain pairs. They used the Coefficient of Determination ($R^2$) and Kendall’s $\tau$ (a rank correlation metric) to evaluate how well the NI score predicted actual model accuracy.

  • Computer Vision: On ImageNet variants (Sketch, Adversarial, Rendition), NI significantly outperformed weight-based norms. NI-RandAug achieved an $R^2$ of 0.709, a substantial improvement over baselines. Tests also included CIFAR-10, SVHN, and MNIST.
  • Natural Language Processing: For RoBERTa models performing sentiment analysis on Amazon reviews (across 10 categories) and Natural Language Inference (MNLI), NI achieved a near-perfect correlation ($R^2 = 0.972$).
  • Extreme OOD: The metric remained reliable even in highly technical shifts, such as moving from general text to medical notes (MedNLI) or drug reviews (Drugs.com).
  • Architectural Robustness: The metric held up across vastly different architectures, from simple CNNs to massive Vision Transformers (ViT) and CLIP models.

Limitations and Future Work

While powerful, NI has certain trade-offs. It is computationally more intensive than simple confidence checks, as it requires multiple forward passes per test point. Additionally, the choice of transformations is critical; they must be "label-preserving" to ensure the metric remains valid. The authors suggest using "Average Entropy Delta" as a diagnostic tool to prune bad transformations.

Finally, NI may fail in cases of "constant classifiers"—models that predict the same class regardless of input—though such cases are rare in practical OOD scenarios. Future research may extend these neighborhood-based measures to real-time OOD Detection, identifying which specific samples are likely to be classified incorrectly during deployment.

Summary updated

BibTeX
@misc{ng2022predicting,
  author = {Nathan Ng and Neha Hulkund and Kyunghyun Cho and Marzyeh Ghassemi},
  title = {{Predicting Out-of-Domain Generalization with Local Manifold Smoothness}},
  year = {2022},
  url = {https://openreview.net/forum?id=klp57bJmaFN},
}
Figure