Out-of-Distribution Detection with Deep Nearest Neighbors

13 Apr 2022  ·  Yiyou Sun, Yifei Ming, Xiaojin Zhu, Yixuan Li ·

Out-of-distribution (OOD) detection is a critical task for deploying machine learning models in the open world. Distance-based methods have demonstrated promise, where testing samples are detected as OOD if they are relatively far away from in-distribution (ID) data. However, prior methods impose a strong distributional assumption of the underlying feature space, which may not always hold. In this paper, we explore the efficacy of non-parametric nearest-neighbor distance for OOD detection, which has been largely overlooked in the literature. Unlike prior works, our method does not impose any distributional assumption, hence providing stronger flexibility and generality. We demonstrate the effectiveness of nearest-neighbor-based OOD detection on several benchmarks and establish superior performance. Under the same model trained on ImageNet-1k, our method substantially reduces the false positive rate (FPR@TPR95) by 24.77% compared to a strong baseline SSD+, which uses a parametric approach Mahalanobis distance in detection. Code is available: https://github.com/deeplearning-wisc/knn-ood.

PDF Abstract
Task Dataset Model Metric Name Metric Value Global Rank Result Benchmark
Out-of-Distribution Detection ImageNet-1k vs iNaturalist KNN (ResNet-50) FPR95 59.08 # 21
AUROC 86.2 # 19
Out-of-Distribution Detection ImageNet-1k vs iNaturalist KNN (ResNet-50 SupCon) FPR95 30.83 # 12
AUROC 94.72 # 13
Out-of-Distribution Detection ImageNet-1k vs Places KNN (ResNet-50) FPR95 77.09 # 22
AUROC 74.87 # 20
Out-of-Distribution Detection ImageNet-1k vs Places KNN (ResNet-50 SupCon) FPR95 60.02 # 16
AUROC 84.62 # 16
Out-of-Distribution Detection ImageNet-1k vs SUN KNN (ResNet-50) FPR95 69.53 # 18
AUROC 80.10 # 16
Out-of-Distribution Detection ImageNet-1k vs SUN KNN (ResNet-50 SupCon) FPR95 48.91 # 14
AUROC 88.40 # 13
Out-of-Distribution Detection ImageNet-1k vs Textures KNN (ResNet-50) FPR95 11.56 # 2
AUROC 97.18 # 5
Out-of-Distribution Detection ImageNet-1k vs Textures KNN (ResNet-50 SupCon) FPR95 16.97 # 5
AUROC 94.45 # 9

Methods


No methods listed for this paper. Add relevant methods here