TL;DR
The paper introduces HAct (Activation Histograms), a simple yet remarkably effective method for detecting out-of-distribution (OOD) inputs in neural networks by modeling layer-wise activation weight distributions. By comparing test-time histograms against class-specific training barycenters via the Wasserstein distance, HAct slashes the false positive rate at 95% true positive rate (FPR95) on ImageNet benchmarks from ~20.7% down to an astonishing 0.03% on ResNet-50.
What Problem Does This Paper Address?
Deep neural networks are typically evaluated under the closed-world assumption that test data follows the same distribution as training data. In real-world deployment, however, novel or anomalous inputs (OOD data) inevitably appear, and networks often make catastrophically confident yet incorrect predictions on them.
While recent post-hoc techniques shape activations (e.g., ReAct, ASH) or prune uninformative weights (e.g., DICE, LINe), they still allow notable false alarm rates. Alternative approaches based on topological data analysis (e.g., persistence graphs) can capture deeper structural shifts but fail to scale computationally to modern convolutional architectures. This paper addresses the need for an OOD detector that is both highly discriminative and computationally lightweight enough for online runtime deployment.
Methods
HAct monitors how an incoming input excites network weights across both fully connected and convolutional layers:
- Activation Histograms (HAct): For a given layer with input $x$ and weight tensor $W$, the activation weights $A_{ij} = |W_{ij} \cdot x_j|$ capture how much feature coordinate $j$ excites weight unit $ij$. HAct models the empirical probability distribution of these scalar weights as a 1D histogram. A cutoff threshold $\varepsilon$ filters out near-zero values resulting from sparse ReLU activations.
- Wasserstein Barycenter Preparation: During an offline preparation step on the training set, HAct calculates an average distribution—the entropy-regularized Wasserstein barycenter—for each target class.
- Multi-Layer Distance Thresholding: At test time, an incoming sample is fed through the model to get the predicted class. The Wasserstein distance between the test sample's layer histogram and the predicted class barycenter is computed. If the distance exceeds a threshold at any monitored layer, the sample is flagged as OOD.
- Channel Sub-Sampling for Scalability: Because convolutional layers generate massive activation weight matrices ($10^6$ to $10^{10}$ entries), HAct uniformly sub-samples the channel dimensions of input and output tensors (e.g., by a factor of 32), dramatically reducing runtime without hurting accuracy.
Incoming Image ──► Deep Network Layer ──► Compute A_ij = |W_ij * x_j|
│ (Sub-sampled & thresholded > ε)
▼
Build 1D Activation Histogram
│
▼
Predicted Class Barycenter ────────► Wasserstein Distance ──► Threshold (OOD if > τ)
Datasets
The authors evaluate HAct across both large-scale and standard smaller benchmarks:
- Large-Scale (ImageNet-1k as In-Distribution): OOD evaluation on four standard benchmarks: Places, SUN, iNaturalist, and Textures.
- CIFAR-10 Benchmark: Split into CIFAR-8 (8 classes for in-distribution training) and CIFAR-2 ("deer" and "ship" as OOD test classes).
- MNIST Benchmark: Standard MNIST digits as in-distribution and Fashion-MNIST (FMNIST) as OOD data.
Key Insights and Ideas
- Distributions reveal what scalar thresholds miss: While earlier methods rely on scalar statistics (e.g., max activation or energy scores), the shape of the activation magnitude distribution changes distinctly between familiar and anomalous patterns.
- Suppressing ReLU zeros is essential: Due to ReLU sparsity, raw activation weights heavily pile up in the zero bin. Setting $\varepsilon > 0$ to cut out near-zero activations prevents this spike from dominating the Wasserstein distance calculations.
- Layer synergy: Combining descriptors from the final dense classification layer with preceding convolutional layers consistently outperforms using any single layer alone.
- Sub-sampling acts as a regularizer: Uniformly skipping channels during activation weight calculation does not just accelerate inference; moderate sub-sampling (factor of 32) actually yielded slightly better OOD separation than computing the full dense graph, likely filtering out noisy connection details.
Key Results
- Large-Scale Benchmark Domination:
- On ResNet-50 (ImageNet ID), HAct reduces average FPR95 to 0.03% with 99.98% AUROC, compared to the prior best method (LINe) at 20.70% FPR95 / 95.03% AUROC.
- On MobileNet-v2, HAct achieves 0.08% FPR95 and 99.98% AUROC, outperforming LINe (29.60% FPR95 / 93.62% AUROC).
- Comparison to Topological Descriptors: On shallow networks (CNN-1 / MNIST vs. FMNIST), HAct reduces FPR95 from 46.50% to 12.50%. On dense layers, HAct is approximately 50× faster than topological uncertainty methods and scales smoothly to convolutional layers where topological methods are intractable.
- Latency: Single-image inference runs in 90 ms on ResNet-50 and 60 ms on MobileNet-v2 on an NVIDIA RTX 3080 GPU.
Limitations and Future Work
- Reliance on Training Data: HAct requires passing training data through the model offline to construct class-wise Wasserstein barycenters, making it difficult to use in privacy-restricted settings where training data cannot be retained. The authors propose exploring methods to infer barycenters directly from the network weights without training data.
- Scope of Architectures: Experiments were restricted to vision CNNs (ResNet, MobileNet, shallow CNNs). The authors identify extending HAct to other neural network architectures (e.g., Vision Transformers or NLP models) as key future work.
Summary updated