LINe: Out-of-Distribution Detection by Leveraging Important Neurons

Yong Hyun Ahn, Gyeong-Moon Park, Seong Tae Kim

TL;DR

LINe (Leveraging Important Neurons) is a novel, post-hoc out-of-distribution (OOD) detection method that identifies and isolates class-specific neurons using Shapley values and activation clipping. Without requiring any model retraining, LINe significantly cuts down false positive rates—reducing FPR95 by up to 14.05% on standard benchmarks—making deep learning models safer for mission-critical deployments.

What Problem Does This Paper Address?

Deep learning models are notoriously overconfident. When presented with out-of-distribution (OOD) data—unseen classes or environments completely different from the training set—they often make highly confident, incorrect predictions. In mission-critical applications like autonomous driving or medical diagnosis, these silent failures can be catastrophic.

To fix this, researchers use OOD detection. "Post-hoc" methods are highly desirable because they work on pre-trained models without needing expensive retraining, which can degrade original model accuracy. However, existing post-hoc methods struggle to filter out "noisy" signals in the final layers of deep networks, often failing to clearly distinguish between in-distribution (ID) and OOD inputs.

Methods

The authors introduce LINe, a post-hoc framework that operates on the penultimate layer of a neural network. It consists of three main components:

  1. Activation Clipping (AC): This technique caps activation values above a certain threshold ($\delta$). By flattening abnormally high activations, the model treats all activated high-level features equally, shifting the focus to the number of activated features rather than their raw magnitude.
  2. Activation Pruning (AP): Using a precomputed contribution matrix based on Shapley values (approximated via Taylor expansion), LINe identifies which neurons contribute most to predicting a specific class and masks out the rest to eliminate noise.
  3. Weight Pruning (WP): Similar to AP, this selectively masks out less important weights in the penultimate layer to reduce the influence of an overparameterized model's noisy signals.

The overall workflow is illustrated below:

Figure 2. Overall procedure of LINe for calculating OOD score. LINe is composed of mainly three parts. 1) Activation Clipping (AC), 2) Activation Pruning (AP), 3) Weight Pruning (WP). AC limits the magnitude of the activation, which allows LINe to consider the number of activated features. AP uses contribution matrix C, which is precomputed from Shapley value [44]. AP leverages C to select important neurons and mask others. WP uses an adjusted contribution matrix which is obtained from the contribution matrix C. Leveraging AP and WP, LINe can reduce noisy signals effectively.

Datasets

The authors evaluated LINe across several standard computer vision benchmarks:

  • In-Distribution (ID) Datasets: CIFAR-10, CIFAR-100, and ImageNet-1K.
  • Out-of-Distribution (OOD) Datasets: SVHN, Textures, iSUN, LSUN-Crop, LSUN-Resize, Places365, iNaturalist, and SUN.

Key Insights and Ideas

  • The Activation Gap: The core "aha moment" of the paper is that ID data and OOD data activate the penultimate layer's neurons differently. ID samples typically activate a vast majority of the neurons, whereas OOD samples activate significantly fewer (see Figure 1).
Figure 1. Illustration of the number of activated neuron in the penultimate layer. The distributions of the number of acti- vated neurons from ID (ImageNet [19]) and two OOD datasets (textures [10] and iNaturalist [52]) are presented. We define an activated neuron as one fired with an activation value greater than zero. Most of the neurons are activated when the model receives ID samples but fewer neurons are activated in OOD samples.
  • Counting over Magnitude: By applying Activation Clipping, the method stops a few highly active "noisy" neurons from dominating the OOD score. This allows the system to effectively leverage the count of activated class-specific features as a reliable proxy for distribution membership.
  • Shapley Values for Pruning: Instead of relying purely on activation magnitude to determine neuron importance (which can be misleading), LINe uses mathematically grounded Shapley values to calculate true class-specific feature contributions.

Key Results

LINe achieves state-of-the-art performance across multiple benchmarks, notably outperforming competitive post-hoc methods like ReAct and DICE:

  • CIFAR-100: LINe achieved an FPR95 (False Positive Rate at a 95% True Positive Rate) of 35.67%, a massive 14.05% reduction compared to DICE's 49.72%.
  • ImageNet: LINe achieved an average FPR95 of 20.70% and an AUROC of 95.03% across four OOD datasets, outperforming DICE + ReAct (27.25% FPR95).
Table 1. Comparison on CIFAR benchmarks. Comparison with competitive post-hoc OOD detection methods on CIFAR bench- marks. All values in this table are percentages and averaged over six OOD test datasets. ↓indicates smaller value means better per- formance and ↑indicates vice versa. Bold numbers are superior results. The overall detail results for each OOD dataset are pro- vided in supplementary material.

The authors also demonstrated that the choice of the clipping threshold ($\delta$) is critical. As shown in the ablation study below, performance peaks at $\delta = 0.8$ for ImageNet before degrading if clipped too aggressively:

Table 4. Ablation on different thresholds (δ) of AC. Ablation on the different thresholds (δ) of clipping. All values are percentages and averaged over multiple OOD test datasets.

Limitations and Future Work

While highly effective, LINe introduces a fundamental trade-off: pruning too many neurons to reduce noise can destroy the model's ability to count class-specific features accurately. Consequently, users must carefully tune hyperparameters—specifically the clipping threshold ($\delta$) and pruning percentiles ($p_w, p_a$)—based on how overparameterized the underlying model is.

The authors hope that viewing OOD detection through the lens of feature presentation and neuron-concept association will inspire future research across adjacent domains.

Summary updated

BibTeX
@misc{ahn2023line,
  author = {Yong Hyun Ahn and Gyeong-Moon Park and Seong Tae Kim},
  title = {{LINe: Out-of-Distribution Detection by Leveraging Important Neurons}},
  year = {2023},
  eprint = {2303.13995},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.13995},
}
Figure