HAct: Out-of-Distribution Detection with Neural Net Activation Histograms

Sudeepta Mondal, Ganesh Sundaramoorthi · DOI

Abstract

Deep learning models often exhibit overconfidence when encountering out-of-distribution (OOD) data, posing significant safety risks in real-world applications. We present HAct (Activation Histograms), a novel OOD detection method that monitors the statistical distributions of neural network layer outputs. By comparing "activation fingerprints" of test data against class-specific Wasserstein barycenters derived from training data, HAct achieves near-perfect detection performance. On ImageNet-1k benchmarks, HAct reduces the False Positive Rate (FPR95) from over 20% to a staggering 0.03%, while maintaining computational efficiency suitable for real-time monitoring.

Introduction

The reliability of deep neural networks in critical deployments, such as autonomous driving and medical diagnostics, is often compromised by their inability to identify novel or unseen data categories. Standard models tend to assign high-confidence scores to OOD samples rather than signaling uncertainty. While existing methods often rely on simple activation magnitudes or computationally expensive topological descriptors, HAct leverages the rich information contained within the distribution of activations—the statistical pattern of how neurons fire in response to specific inputs.

Methodology: Activation Histograms (HAct)

The core of the HAct method is the creation of a statistical "fingerprint" for each class at various network layers.

Activation Weights and Histograms

For a given layer, HAct calculates activation weights $A_{ij} = |W_{ij} \cdot x_j|$, representing the contribution of input coordinate $x_j$ to output unit $i$ via weight $W_{ij}$. Instead of simple summary statistics like mean or max, a histogram of these weights is constructed to capture the full "shape" of the layer's response to an input.

The HAct Pipeline

  1. Preparation: Using in-distribution training data, class-specific Wasserstein barycenters (specialized statistical averages) of activation histograms are computed for each layer.
  2. Detection: During inference, the histogram of a new input is compared to the barycenter of its predicted class using the Wasserstein distance. If this distance exceeds a threshold, the data is flagged as OOD.
  3. Efficiency: To handle high-dimensional convolutional layers, the authors employ sub-sampling of input-output connections, maintaining high throughput without sacrificing detection accuracy.
Overview of the HAct pipeline, showing the generation of activation histograms and their comparison to class-specific barycenters for OOD detection.

Experimental Evaluation

HAct was evaluated using ResNet-50 and MobileNet-v2 architectures on standard, rigorous OOD benchmarks:

  • In-Distribution (ID): CIFAR-10 (8 classes) and ImageNet-1k.
  • Out-of-Distribution (OOD): Remaining CIFAR classes, and datasets such as Places, SUN, iNaturalist, and Textures for ImageNet.

Results and Discussion

HAct demonstrates a significant leap in OOD detection performance compared to previous state-of-the-art (SoA) methods.

Quantitative Performance

On ImageNet-1k with ResNet-50, HAct achieved an average FPR95 of 0.03%, a dramatic improvement over the previous best method, LINe, which recorded 20.70%. AUROC scores consistently reached near-perfection (99.98%–99.99%) across various OOD datasets.

Multi-Layer Fusion

A key insight is the synergy between different layer types. Combining histograms from final dense layers (capturing high-level semantic shifts) with preceding convolutional layers (capturing lower-level structural anomalies) provides the most robust detection.

ROC curves and performance metrics (FPR95 and AUROC) demonstrating the superior performance of combining dense and convolutional layer scores in the HAct classifier.

Computational Efficiency

Despite its statistical depth, HAct is optimized for production. It runs approximately 50x faster than previous topological uncertainty methods, with inference times between 60-90ms on a standard RTX 3080, making it viable for online monitoring.

Conclusion and Future Work

HAct provides a powerful, distribution-based approach to OOD detection that significantly outperforms magnitude-based thresholding. While it currently requires access to training data to compute class barycenters, it sets a new benchmark for accuracy. Future research will focus on approximating these barycenters directly from model weights to enhance portability for pre-trained "black box" models.

Summary updated

BibTeX
@misc{mondal2023hact,
  author = {Sudeepta Mondal and Ganesh Sundaramoorthi},
  title = {{HAct: Out-of-Distribution Detection with Neural Net Activation Histograms}},
  year = {2023},
  eprint = {2309.04837},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.04837},
}
Figure