ICML 2025

Mahalanobis++: Improving OOD Detection via Feature Normalization
Maximilian M¨uller 1 Matthias Hein 1
Abstract
Detecting out-of-distribution (OOD) examples
is an important task for deploying reliable ma-
chine learning models in safety-critial applica-
tions. While post-hoc methods based on the Ma-
halanobis distance applied to pre-logit features
are among the most effective for ImageNet-scale
OOD detection, their performance varies signif-
icantly across models. We connect this incon-
sistency to strong variations in feature norms,
indicating severe violations of the Gaussian as-
sumption underlying the Mahalanobis distance es-
timation. We show that simple ℓ2-normalization
of the features mitigates this problem effectively,
aligning better with the premise of normally dis-
tributed data with shared covariance matrix. Ex-
tensive experiments on 44 models across diverse
architectures and pretraining schemes show that
ℓ2-normalization improves the conventional Ma-
halanobis distance-based approaches significantly
and consistently, and outperforms other recently
proposed OOD detection methods. Code is avail-
able at github.com/mueller-mp/maha-norm.
1. Introduction
Deep neural networks have demonstrated remarkable perfor-
mance across a variety of real-world tasks. However, when
faced with inputs that fall outside their training distribu-
tion, they can behave unpredictably and even result in high-
confidence predictions (Hendrycks & Gimpel, 2017; Hein
et al., 2019). These so-called out-of-distribution (OOD) in-
puts are often misclassified with high confidence as belong-
ing to the in-distribution (ID) classes, creating significant
risks for real-world deployments. OOD detectors aim to
identify and reject such anomalous inputs — potentially
prompting human intervention, transitioning to a safe state,
or declining to provide a prediction — while still allowing
1University of T¨ubingen and T¨ubingen AI Center.
Corre-
spondence to: Maximilian M¨uller <maximilian.mueller@...