WeiPer: OOD Detection using Weight Perturbations of Class Projections
Maximilian Granz, Manuel Heurich, Tim Landgraf
TL;DR
WeiPer proposes a simple yet effective post-hoc OOD detection method by perturbing the final-layer class projections to create an augmented logit space. It introduces two scoring approaches: MSP_W, which averages MSP over multiple perturbations, and WeiPer+KLD, a KL-divergence based detector that compares penultimate-layer distributions with their perturbed counterparts, optionally combined with MSP_W. Across CIFAR and ImageNet benchmarks within OpenOOD, WeiPer+KLD attains state-of-the-art performance on many near-OOD tasks, with substantial gains over strong baselines (notably on near-ImageNet using ResNet50); MSP_W and WeiPer+ReAct also show consistent improvements. Limitations include additional hyperparameters and increased memory usage for large perturbation spaces, while ViT backbones can experience diminished gains due to lower penultimate-space dimensionality. Overall, WeiPer provides a versatile, post-hoc enhancement to OOD detection that leverages structured class-projection perturbations to better separate ID and OOD distributions in practice.
Abstract
Recent advances in out-of-distribution (OOD) detection on image data show that pre-trained neural network classifiers can separate in-distribution (ID) from OOD data well, leveraging the class-discriminative ability of the model itself. Methods have been proposed that either use logit information directly or that process the model's penultimate layer activations. With "WeiPer", we introduce perturbations of the class projections in the final fully connected layer which creates a richer representation of the input. We show that this simple trick can improve the OOD detection performance of a variety of methods and additionally propose a distance-based method that leverages the properties of the augmented WeiPer space. We achieve state-of-the-art OOD detection results across multiple benchmarks of the OpenOOD framework, especially pronounced in difficult settings in which OOD samples are positioned close to the training set distribution. We support our findings with theoretical motivations and empirical observations, and run extensive ablations to provide insights into why WeiPer works.
