NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Out-of-Distribution Detection Using Union of 1-Dimensional Subspaces

Alireza Zaeemzadeh, Niccoló Bisagno, Zeno Sambugaro, Nicola Conci, Nazanin Rahnavard, Mubarak ShahCVPR 2021

Abstract

The goal of out-of-distribution (OOD) detection is to handle the situations where the test samples are drawn from a different distribution than the training data. In this paper, we argue that OOD samples can be detected more easily if the training data is embedded into a low-dimensional space, such that the embedded training samples lie on a union of 1-dimensional subspaces. We show that such embedding of the in-distribution (ID) samples provides us with two main advantages. First, due to compact representation in the feature space, OOD samples are less likely to occupy the same region as the known classes. Second, the first singular vector of ID samples belonging to a 1-dimensional subspace can be used as their robust representative. Motivated by these observations, we train a deep neural network such that the ID samples are embedded onto a union of 1-dimensional subspaces. At the test time, employing sampling techniques used for approximate Bayesian inference in deep learning, input samples are detected as OOD if they occupy the region corresponding to the ID samples with probability 0. Spectral components of the ID samples are used as robust representative of this region. Our method does not have any hyperparameter to be tuned using extra information and it can be applied on different modalities with minimal change. The effectiveness of the proposed method is demonstrated on different benchmark datasets, both in the image and video classification domains.

Introduction

Deep learning models are notoriously overconfident. When presented with an input from a category they’ve never seen before, they often assign it to a known class with high certainty rather than admitting uncertainty. Standard OOD detection methods often rely on the softmax probabilities of a pre-trained classifier or measure the distance to "Gaussian blobs" of training data in feature space. However, these Gaussian embeddings are often "fat" — they occupy a significant volume of the feature space, making it easy for OOD samples to accidentally fall inside them.

This paper addresses this by creating a more "compact" representation of known data. By "thinning out" the in-distribution (ID) representation from a volume to a 1-dimensional line (subspace), the model maximizes the "empty" space available to catch OOD samples. Mathematically, a 1D line has zero volume in a high-dimensional space, meaning the probability of a random OOD vector falling exactly on a specific line is effectively zero.

Methodology

The authors introduce two primary structural constraints during training to reshape the feature space:

  1. Intraclass Constraint: Instead of standard cross-entropy, they use a loss function based on absolute cosine similarity. This forces all feature vectors belonging to a specific class to align along a single 1-dimensional line passing through the origin.
  2. Interclass Constraint: To ensure these class-specific lines don't overlap, the weights of the final fully connected layer are initialized as orthonormal vectors and frozen. This forces the 1D subspaces of different classes to be perpendicular to one another.
Overview of the proposed OOD detection pipeline, illustrating the training process with orthogonality constraints and the testing process using spectral discrepancy and Monte Carlo sampling.

At inference time, the model calculates the Spectral Discrepancy: the minimum angle between a test sample's feature vector and the first singular vectors (the most robust representatives) of the training classes. Uncertainty is estimated using Monte Carlo (MC) sampling (specifically SWAG-Diag) to estimate the probability that a sample belongs to the ID region. If the probability of being near any of the 1D subspaces is near zero, the sample is rejected as OOD.

Visualizing the Subspace Advantage

The core advantage of this method is the reduction of the volume occupied by in-distribution data. In standard training, both ID and OOD samples tend to cluster in similar regions of the feature space. By forcing ID samples onto 1D subspaces, the OOD samples — which do not follow these constraints — remain spread across the feature sphere, making them significantly easier to distinguish.

Comparison of feature space distributions: (a) and (b) show standard ID and OOD distributions; (c) and (d) show the proposed method where ID samples are constrained to lines, leaving OOD samples clearly separated on the sphere.

Experimental Results

The proposed method consistently outperformed state-of-the-art baselines across multiple metrics:

  • Image Classification: On CIFAR-10 (ID) vs. LSUN (OOD), the method achieved an AUROC of 99.4%, significantly higher than the standard Softmax baseline (94.5%). It also drastically reduced the False Positive Rate (FPR) at 95% TPR; for CIFAR-100 vs. LSUN-resize, the FPR dropped from 82.2% to 20.3%.
  • Video Action Recognition: The method showed strong performance in video action recognition using UCF101 and HMDB51, outperforming the Softmax thresholding baseline by a wide margin.

Notably, this approach does not require a separate validation set of OOD samples to tune hyperparameters, making it highly practical for real-world deployment where the nature of future "unknowns" is unpredictable.

Conclusion and Future Work

While enforcing strict geometric constraints can slightly decrease standard classification accuracy (e.g., a drop from 96.0% to 95.4% on CIFAR-10), the gains in OOD robustness are substantial. The method also requires the feature space dimension to be greater than the number of classes to maintain orthogonality. Future work may extend this framework to higher-dimensional subspaces or apply it to other modalities like audio or sensor data.

Summary updated

BibTeX
@inproceedings{zaeemzadeh2021out,
  author = {Alireza Zaeemzadeh and Niccoló Bisagno and Zeno Sambugaro and Nicola Conci and Nazanin Rahnavard and Mubarak Shah},
  title = {{Out-of-Distribution Detection Using Union of 1-Dimensional Subspaces}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  url = {https://openreview.net/forum?id=b9zf_rraqV},
}
Figure