Hyperdimensional Feature Fusion for Out-Of-Distribution Detection

Samuel Wilson, Tobias Fischer, Niko Sünderhauf, Feras DayoubarXiv 2021

TL;DR

Researchers have developed Hyperdimensional Feature Fusion (HDFF), a novel method for Out-of-Distribution (OOD) detection that leverages Hyperdimensional Computing to fuse signals from multiple layers of a neural network. By projecting internal features into a massive $10^4$-dimensional space and "bundling" them together, HDFF creates a robust visual fingerprint that identifies OOD samples significantly faster than current state-of-the-art methods while maintaining competitive accuracy.

What Problem Does This Paper Address?

Deep Neural Networks (DNNs) are notoriously overconfident. When shown an image of something they weren't trained on—an "Out-of-Distribution" (OOD) sample—they often "fail silently," assigning a high-confidence score to a completely wrong class. This is a major safety hurdle for autonomous systems like self-driving cars or medical diagnostics.

Most existing OOD detection techniques look only at the final layer of a network (the softmax probabilities or logits). However, the "OOD-ness" of an image might be apparent in earlier layers that capture textures or shapes, even if the final layer is fooled. The challenge is that raw feature maps from multiple layers are high-dimensional and difficult to combine efficiently without losing information.

Methods

The authors turn to Hyperdimensional Computing (HDC), a framework inspired by the brain's use of massive, distributed representations. Their approach, HDFF, follows three main steps:

  1. Feature Extraction & Pooling: They extract feature maps from various layers of a pre-trained DNN and use max-pooling to turn them into vectors.
  2. Similarity-Preserving Projection: To combine features of different sizes, they project them into a common $10^4$-dimensional space. Crucially, they use semi-orthogonal projection matrices. This ensures that if two feature vectors are similar in their original space, their high-dimensional projections remain similar.
  3. Bundling: In HDC, "bundling" (element-wise addition) allows multiple vectors to be combined into one while retaining similarity to all original components. HDFF bundles the features from all selected layers into a single "image descriptor."
  4. Class Descriptors: During training, they bundle all image descriptors for a specific class (e.g., all "trucks") into one "class descriptor."

At test time, the system calculates the cosine similarity (the angle) between a new image's descriptor and all known class descriptors. If the angle to the closest class is larger than a specific threshold, the image is flagged as OOD.

Datasets

The authors evaluated HDFF using standard benchmarks in the field:

  • In-Distribution (ID): CIFAR-10 and CIFAR-100.
  • Out-of-Distribution (OOD): A diverse suite including SVHN (house numbers), MNIST (digits), FashionMNIST, Textures, iSUN, LSUN, and TinyImageNet.
  • Near-OOD: The challenging task of distinguishing CIFAR-10 from CIFAR-100 (e.g., telling a "truck" from a "pickup truck").

Key Insights and Ideas

  • The Power of Fusion: The paper demonstrates that no single layer is the "best" for OOD detection across all datasets. Fusing multiple layers provides a "best of all worlds" performance that is more robust than any individual layer.
  • Efficiency through Linearity: Unlike the popular "Gram Matrix" approach—which requires calculating $O(n^2)$ correlations between channels—HDFF scales linearly $O(n)$ with the number of channels. This makes it roughly 4.5x faster during inference.
  • Angles as Visual Similarity: Because the projections preserve similarity, the angular distance between vectors acts as a proxy for visual dissimilarity. The authors show that images within 15° of a "truck" descriptor look like trucks, while those beyond 30° are clearly non-vehicles or obscured objects.
  • Orthogonality: HDFF is "orthogonal" to other methods, meaning it can be combined with specialized training losses (like 1D Subspaces) or auxiliary classifiers (MLPs) to further boost performance.

Key Results

  • Competitive Accuracy: HDFF performs on par with or better than state-of-the-art statistical methods like Gram matrices and Energy-based models. In the "training stream" (methods that allow retraining), combining HDFF with an MLP achieved an average AUROC of 95.2% on CIFAR-10 tasks.
  • Speed: HDFF adds minimal overhead. A full pass of the CIFAR-10 test set took ~7.0 seconds with HDFF, compared to ~6.0 seconds for a standard inference pass. The competing Gram matrix method took ~31.4 seconds.
  • Minimal Calibration: Unlike some SOTA methods that require 60-100 epochs of training on "proxy OOD" data, HDFF only requires a single pass through the training set to collect class statistics.

Limitations and Future Work

  • Near-OOD Challenges: Like most detectors, HDFF struggles with "Near-OOD" samples (e.g., CIFAR-10 vs CIFAR-100). The angular distributions of these sets overlap significantly, making it hard to set a single threshold that catches all OOD samples without flagging ID samples.
  • Layer Weighting: Currently, all layers are bundled with equal weight. The authors suggest that future work could investigate weighting layers differently based on their predicted importance for a specific task.
  • HDC Operations: This paper primarily uses "bundling." The authors note that other HDC operations, like "binding" (which creates a representation dissimilar to its components), could open new research directions for DNN monitoring.

Summary updated

Abstract

We introduce powerful ideas from Hyperdimensional Computing into the challenging field of Out-of-Distribution (OOD) detection. In contrast to most existing work that performs OOD detection based on only a single layer of a neural network, we use similarity-preserving semi-orthogonal projection matrices to project the feature maps from multiple layers into a common vector space. By repeatedly applying the bundling operation $\oplus$, we create expressive class-specific descriptor vectors for all in-distribution classes. At test time, a simple and efficient cosine similarity calculation between descriptor vectors consistently identifies OOD samples with better performance than the current state-of-the-art. We show that the hyperdimensional fusion of multiple network layers is critical to achieve best general performance.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
iSUNHDFFAUROC99.2%Far-OOD detection with CIFAR10 as the in-distribution dataset; statistics stream; WideR…
Source quote
L336: iSun │ 99.2 │ 99.3 │ 99.9 │ 96.4 │ 97.8 │ 92.6
iSUNGramAUROC99.9%Far-OOD detection with CIFAR10 as the in-distribution dataset; statistics stream; Gram …
Source quote
L336: iSun │ 99.2 │ 99.3 │ 99.9 │ 96.4 │ 97.8 │ 92.6
SVHNHDFFAUROC99.4%Far-OOD detection with CIFAR10 as the in-distribution dataset; statistics stream; WideR…
Source quote
L341: SVHN │ 99.4 │ 99.5 │ 99.4 │ 96.0 │ 97.2 │ 91.0
BibTeX
@misc{wilson2021hyperdimensional,
  author = {Samuel Wilson and Tobias Fischer and Niko Sünderhauf and Feras Dayoub},
  title = {{Hyperdimensional Feature Fusion for Out-Of-Distribution Detection}},
  year = {2021},
  eprint = {2112.05341},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.05341},
}
Figure