Close Category Generalization

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

Abstract

We study out-of-distribution (OOD) prediction behavior of neural networks when they classify images from unseen classes or corrupted images. To probe the OOD behavior, we introduce a new measure, nearest category generalization (NCG), where we compute the fraction of OOD inputs that are classified with the same label as their nearest neighbor in the training set. Our motivation stems from understanding the prediction patterns of adversarially robust networks, since previous work has identified unexpected consequences of training to be robust to norm-bounded perturbations. We find that robust networks have consistently higher NCG accuracy than natural training, even when the OOD data is much farther away than the robustness radius. This implies that the local regularization of robust training has a significant impact on the network's decision regions. We replicate our findings using many datasets, comparing new and existing training methods. Overall, adversarially robust networks resemble a nearest neighbor classifier when it comes to OOD data.

Introduction

Deep learning models often exhibit unpredictable behavior when encountering out-of-distribution (OOD) data, such as images from novel categories or heavily corrupted inputs. While significant research has focused on OOD detection, the underlying patterns of the labels assigned to such data remain poorly understood.

A particularly intriguing phenomenon occurs in adversarially robust training. Methods like TRADES regularize networks to be "smooth" within a small $\epsilon$-ball around training points. While intended to prevent local evasion attacks, this local constraint has been observed to have "global" side effects far from the training data. This paper introduces Nearest Category Generalization (NCG) to quantify this behavior, investigating whether robust training forces models to adopt a more geometric, nearest-neighbor-like approach to generalization.

Methods

The core of this study is the Nearest Category Generalization (NCG) metric. For any OOD image, we identify its 1-Nearest Neighbor (1-NN) in the training set using $L_2$ distance. If the model’s predicted label matches the label of this nearest neighbor, it contributes to the NCG score.

Illustration of Nearest Category Generalization (NCG). An OOD input (digit 9) is classified as its nearest neighbor in the training set (digit 4).

NCG is evaluated in two distinct spaces:

  1. Pixel Space: Using raw input values.
  2. Feature Space: Using latent embeddings from the network's final layer.

The study compares "Natural" training against "Robust" training (Adversarial Training and TRADES) and "Mixup" across several benchmarks, including "leave-one-out" versions of MNIST and CIFAR-10, and corrupted variants like CIFAR-10-C.

Key Insights: Local Regularization, Global Impact

A central finding is that adversarial training significantly increases NCG, even though the robustness radius is typically much smaller than the distance to OOD points. This suggests that local regularization "straightens out" decision boundaries, extending them deep into the input space.

Conceptual diagram showing the local robustness radius r compared to the much larger distance to OOD examples.

This behavior implies that robust networks act more like 1-NN classifiers on OOD data. For instance, a model trained on digits 0-8 that encounters a "9" is more likely to label it a "4" (its closest visual relative) if it is robustly trained, rather than assigning a seemingly random label.

Results

Experimental results across all datasets show a consistent NCG boost for robust models. On MNIST, TRADES achieved an NCG of ~0.59 compared to ~0.49 for natural training. On CIFAR-10, the gap was even wider (~0.34 vs ~0.24).

Key observations include:

  • Distance Correlation: NCG scores are higher when OOD examples are closer to the training set; the effect weakens as $L_2$ distance increases.
  • Feature Space Dominance: In feature space, NCG scores often exceed 0.80 for CIFAR-10, suggesting highly organized internal representations.
  • Safety Implications: On corrupted data, NCG correlates positively with accuracy, suggesting that matching the 1-NN label is a statistically safer "fallback" prediction.

Conclusion

Adversarially robust training fundamentally reshapes a model's global decision boundaries to resemble a nearest-neighbor classifier. This geometric grounding provides a more predictable failure mode for OOD data. Future work should explore alternative distance metrics and evaluate NCG in safety-critical domains like autonomous driving or medical imaging.

Summary updated

BibTeX
@article{yang2023close,
  author = {Yao-Yuan Yang and Cyrus Rashtchian and Ruslan Salakhutdinov and Kamalika Chaudhuri},
  title = {{Close Category Generalization}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2023},
}
Figure