GradPCA: Leveraging NTK Alignment for Reliable Out-of-Distribution Detection
Mariia Seleznova, Hung-Hsu Chou, Claudio Mayrink Verdun, Gitta Kutyniok
TL;DR
This work introduces GradPCA, a principled spectral OOD detector that exploits the NTK-aligned, low-rank structure of neural network gradients. By applying PCA to gradient class-means, GradPCA effectively captures a class-specific subspace in gradient space, enabling reliable OOD detection with strong theoretical grounding. The authors provide a spectral OOD framework, detailing sufficient and necessary conditions, and demonstrate GradPCA’s robust, near state-of-the-art performance across CIFAR and ImageNet benchmarks, while highlighting the critical role of feature quality (pretrained vs non-pretrained representations). The work also offers practical guidance for detector design, emphasizes consistency over ad hoc performance, and releases open-source code to foster reproducibility and further research in principled OOD detection. Overall, GradPCA bridges NTK theory with spectral OOD detection, enabling more reliable and interpretable detection in real-world deep learning systems.
Abstract
We introduce GradPCA, an Out-of-Distribution (OOD) detection method that exploits the low-rank structure of neural network gradients induced by Neural Tangent Kernel (NTK) alignment. GradPCA applies Principal Component Analysis (PCA) to gradient class-means, achieving more consistent performance than existing methods across standard image classification benchmarks. We provide a theoretical perspective on spectral OOD detection in neural networks to support GradPCA, highlighting feature-space properties that enable effective detection and naturally emerge from NTK alignment. Our analysis further reveals that feature quality -- particularly the use of pretrained versus non-pretrained representations -- plays a crucial role in determining which detectors will succeed. Extensive experiments validate the strong performance of GradPCA, and our theoretical framework offers guidance for designing more principled spectral OOD detectors.
