Boosting Out-of-Distribution Detection with Sample Weighting
摘要
To enhance the reliability of machine learning models in the open world, there is considerable interest in detecting out-of-distribution (OOD) inputs that lie far away from the training distribution. Existing distance-based methods have shown promising performance in OOD detection. These methods generally follow a common approach of capturing the distances between training samples and each test sample in the feature space. This can be understood as encoding the distance information to assign sample weights, which are then used to calculate a weighted distance score to determine if the input is OOD. However, these methods often adopt a coarse-grained weighting approach, where only a small fraction of the training samples are considered and given weights. Consequently, they fail to fully leverage the complete distance information of the training data, leading to occasional difficulties in effectively distinguishing OOD samples. In this paper, we propose a novel approach to encode the complete distance information of the training data by assigning a weight to each sample based on its distance from the test sample, with the weights decaying as the distance increases. Furthermore, we introduce a weighted distance-based method for OOD detection. We demonstrate the superiority of our method over most existing supervised OOD detectors. Particularly, on a hard OOD detection task involving CIFAR-100 vs. CIFAR-10, our method achieves a reduction of \(1.82\%\) in the average FPR95 compared to the current best method KNN.