Probing Predictions on OOD Images via Nearest Categories

Yao-Yuan Yang, Cyrus Rashtchian, Ruslan Salakhutdinov, Kamalika Chaudhuri

TL;DR

This paper introduces Nearest Category Generalization (NCG), a new metric revealing that adversarially robust neural networks behave surprisingly like nearest-neighbor classifiers when faced with out-of-distribution (OOD) data. The findings suggest that local robustness training has a profound, unintended global impact, forcing models to extrapolate based on the raw geometry of the input space.

What Problem Does This Paper Address?

Deep neural networks are notoriously unpredictable when they encounter data they haven't seen before—known as out-of-distribution (OOD) data. This includes images from entirely new categories (e.g., showing a model trained on digits 0–8 a picture of a 9) or images that have been heavily corrupted by noise or blur.

While researchers have developed "local" regularization techniques (like adversarial training) to make models robust to tiny, invisible perturbations, we still don't fully understand how these models behave "globally"—far away from the training data. Are their predictions on OOD data just random noise, or is there a hidden pattern? This paper seeks to uncover that pattern.

Methods

The authors introduce a simple but powerful metric: Nearest Category Generalization (NCG).

  • The NCG Score: For any OOD image, find its 1-nearest neighbor (1-NN) in the training set using standard Euclidean ($\ell_2$) distance. If the model predicts the same label for the OOD image as that of its nearest neighbor, it counts toward the NCG score.
  • Probing Robustness: They compare "naturally" trained models against those trained with adversarial defense methods like TRADES and standard Adversarial Training (AT).
  • Sub-Voronoi Regions: They explore a theoretical framework where a model is encouraged to be "smooth" within the Voronoi cell of a training point (the region of space closer to that point than any other). They test different approximations of these regions, such as ellipsoids and non-uniform balls, to see if they can actively boost NCG.

Datasets

The study uses a wide range of standard benchmarks and their OOD variants:

  • MNIST, CIFAR-10, CIFAR-100, and ImageNet-100: Used for "Unseen Class" experiments where one or more categories are held out during training.
  • Corrupted Data: They utilize CIFAR10-C, CIFAR100-C, and ImgNet100-C, which contain 15–18 types of algorithmic corruptions (like Gaussian noise, fog, or JPEG artifacts) at various severity levels.

Key Insights and Ideas

  • Robustness Breeds Nearest-Neighbor Behavior: The most striking finding is that adversarially robust networks have consistently higher NCG scores than naturally trained ones. Even though OOD images are much further away than the "robustness radius" used during training, the model still "extrapolates" the label of the nearest training point.
  • Geometry Trumps Semantics: This behavior occurs in raw pixel space. It suggests that robust training forces the network to rely on the low-level geometry of the input space rather than just high-level semantic features when it's "unsure."
  • NCG as a Quality Signal: For corrupted images, the authors found a strong correlation: if a model's prediction matches the 1-NN label (high NCG), it is significantly more likely to actually be the correct semantic label.
  • Sample Efficiency: Theoretically, the authors prove that achieving a high NCG score is "easier" (requires fewer training samples) than perfect OOD detection. This makes NCG a more practical target for building predictable AI systems.

Key Results

  • Higher NCG Scores: Across 80 different models, robust versions (TRADES/AT) almost always had higher NCG scores than natural training. For instance, on CIFAR-10, robust models achieved NCG scores around 0.34–0.37, compared to 0.24 for natural training (where chance is ~0.11).
  • Global Impact of Local Rules: In 186 out of 190 test cases, OOD images were found to be significantly outside the empirical robust radius, yet the models still favored the 1-NN label.
  • Statistical Significance: Using Welch’s t-tests, the authors confirmed that "NCG-correct" examples have a significantly higher test accuracy than "NCG-incorrect" ones across nearly all corruption types.

Limitations and Future Work

  • Distance Metric Dependency: The study focuses almost exclusively on $\ell_2$ (Euclidean) distance. The authors acknowledge that exploring other metrics, like $\ell_\infty$ or cosine similarity, is a necessary next step.
  • Feature Space Ambiguity: While NCG behavior was clear in pixel space, the results in "feature space" (latent embeddings) were less consistent for corrupted data, suggesting the learned embeddings might not capture the same geometric properties.
  • Expanding the Scope: Future work could evaluate NCG on different architectures (like Vision Transformers) or against other types of OOD shifts, such as spurious correlations or distribution shifts in medical or satellite imagery.

Summary updated

BibTeX
@article{yang2023probing,
  author = {Yao-Yuan Yang and Cyrus Rashtchian and Ruslan Salakhutdinov and Kamalika Chaudhuri},
  title = {{Probing Predictions on OOD Images via Nearest Categories}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2023},
}
Figure