A Simple Fix to Mahalanobis Distance for Improving Near-OOD Detection

Jie Ren, Stanislav Fort, Jeremiah Liu, Abhijit Guha Roy, Shreyas Padhy +1 more
6/16/2021
cs.LG

Official code: google/uncertainty-baselines (1,602 stars, Apache-2.0, TensorFlow, last commit 2026-03-24).

Abstract

Mahalanobis distance (MD) is a simple and popular post-processing method for detecting out-of-distribution (OOD) inputs in neural networks. We analyze its failure modes for near-OOD detection and propose a simple fix called relative Mahalanobis distance (RMD) which improves performance and is more robust to hyperparameter choice. On a wide selection of challenging vision, language, and biology OOD benchmarks (CIFAR-100 vs CIFAR-10, CLINC OOD intent detection, Genomics OOD), we show that RMD meaningfully improves upon MD performance (by up to 15% AUROC on genomics OOD).

View on arXivView PDF

Code Implementations(1)

TensorFlowApache-2.0

High-quality implementations of standard and SOTA methods on a variety of tasks.

1,602225Python, Jupyter NotebookJul 16, 20207 months agoApache-2.0
bayesian-methodsdata-sciencedeep-learningmachine-learningneural-networks+3 more

Similar Papers

Cite this paper

@article{ren2021simple,
  title  = {A Simple Fix to Mahalanobis Distance for Improving Near-OOD Detection},
  author = {Jie Ren and Stanislav Fort and Jeremiah Liu and Abhijit Guha Roy and Shreyas Padhy and Balaji Lakshminarayanan},
  year   = {2021},
  eprint = {2106.09022},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2106.09022}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2106.09022.svg)](https://codeofpaper.com/paper/2106.09022)

Discussion