ViM: Out-Of-Distribution with Virtual-logit Matching

CVPR 2022  ·  Haoqi Wang, Zhizhong Li, Litong Feng, Wayne Zhang ·

Most of the existing Out-Of-Distribution (OOD) detection algorithms depend on single input source: the feature, the logit, or the softmax probability. However, the immense diversity of the OOD examples makes such methods fragile. There are OOD samples that are easy to identify in the feature space while hard to distinguish in the logit space and vice versa. Motivated by this observation, we propose a novel OOD scoring method named Virtual-logit Matching (ViM), which combines the class-agnostic score from feature space and the In-Distribution (ID) class-dependent logits. Specifically, an additional logit representing the virtual OOD class is generated from the residual of the feature against the principal space, and then matched with the original logits by a constant scaling. The probability of this virtual logit after softmax is the indicator of OOD-ness. To facilitate the evaluation of large-scale OOD detection in academia, we create a new OOD dataset for ImageNet-1K, which is human-annotated and is 8.8x the size of existing datasets. We conducted extensive experiments, including CNNs and vision transformers, to demonstrate the effectiveness of the proposed ViM score. In particular, using the BiT-S model, our method gets an average AUROC 90.91% on four difficult OOD benchmarks, which is 4% ahead of the best baseline. Code and dataset are available at

PDF Abstract CVPR 2022 PDF CVPR 2022 Abstract
Task Dataset Model Metric Name Metric Value Global Rank Uses Extra
Training Data
Result Benchmark
Out-of-Distribution Detection ImageNet-1K vs ImageNet-O ViM (ViT-B/16) AUROC 92.55 # 2
FPR95 36.75 # 2
Out-of-Distribution Detection ImageNet-1k vs iNaturalist ViM (ViT-B/16) FPR95 2.60 # 2
AUROC 99.41 # 2
Out-of-Distribution Detection ImageNet-1k vs OpenImage-O ViM (ViT-B/16) FPR95 12.61 # 2
AUROC 97.61 # 2
Out-of-Distribution Detection ImageNet-1k vs Textures ViM (BiT-S-R101×1) FPR95 4.69 # 1
Out-of-Distribution Detection ImageNet-1k vs Textures ViM (BiT) AUROC 98.92 # 1
Out-of-Distribution Detection ImageNet-1k vs Textures ViM (ViT-B/16) FPR95 20.31 # 8
AUROC 95.34 # 8