GradAlign: Detecting Out-of-Distribution Samples via Gradient Concentration
摘要
Real-world deployment requires neural networks to operate in open environments where test inputs differ from training data, yet models confidently misclassify out-of-distribution (OOD) samples they have never seen. We discover why: OOD samples exhibit concentrated gradient structure with over 70% energy in a single direction, while in-distribution samples maintain dispersed gradients below 40% concentration. This gradient concentration principle reveals that OOD inputs activate spurious shortcuts that dominate predictions, unlike ID samples that use diverse semantic features. We formalize this through spectral analysis of the predictive Fisher information matrix, proving concentration emerges from single-feature reliance. Based on this insight, we develop GradAlign, which identifies and removes the dominant gradient direction causing overconfidence. Using efficient power iteration and linear extrapolation, our method adds only 11% computational overhead. Experiments show GradAlign achieves state-of-the-art results, reducing false positive rates by 48% while processing 30,000 images per second on GPUs. This work provides the first geometric explanation for OOD failures and demonstrates how theoretical understanding enables practical solutions.