[Paper Review] Hyperparameter-Free Out-of-Distribution Detection Using Softmax of Scaled Cosine Similarity
This paper proposes a hyperparameter-free out-of-distribution (OOD) detection method that uses the softmax of scaled cosine similarity between feature embeddings and class prototypes. By replacing the final layer of a neural network with a cosine similarity-based classifier, the method achieves state-of-the-art OOD detection performance without requiring OOD validation data, outperforming prior methods on a challenging benchmark that evaluates hyperparameter robustness while maintaining computational efficiency with a single forward pass.
The ability to detect out-of-distribution (OOD) samples is vital to secure the reliability of deep neural networks in real-world applications. Considering the nature of OOD samples, detection methods should not have hyperparameters that need to be tuned depending on incoming OOD samples. However, most of the recently proposed methods do not meet this requirement, leading to compromised performance in real-world applications. In this paper, we propose a simple, hyperparameter-free method based on softmax of scaled cosine similarity. It resembles the approach employed by modern metric learning methods, but it differs in details; the differences are essential to achieve high detection performance. We show through experiments that our method outperforms the existing methods on the evaluation test recently proposed by Shafaei et al., which takes the above issue of hyperparameter dependency into account. We also show that it achieves at least comparable performance to other methods on the conventional test, where their hyperparameters are chosen using explicit OOD samples. Furthermore, it is computationally more efficient than most of the previous methods, since it needs only a single forward pass.
Motivation & Objective
- To address the critical limitation in existing OOD detection methods that require hyperparameters tuned on OOD validation data, which is impractical in real-world deployment.
- To develop a method that maintains high OOD detection performance without relying on access to OOD samples during calibration.
- To improve computational efficiency by eliminating iterative or backpropagation-heavy operations such as input perturbation.
- To demonstrate that technical differences in cosine similarity scaling and normalization are essential for high OOD detection performance, distinguishing it from standard metric learning approaches.
Proposed method
- Replaces the final fully connected layer of a deep neural network with a cosine similarity-based classifier that computes similarity between the final feature representation and learnable class prototypes.
- Applies scaling to the cosine similarity scores using a learnable temperature parameter, followed by a softmax operation to produce class probabilities.
- Trains the network using standard cross-entropy loss on in-distribution data only, without any OOD-specific loss or data.
- Uses the maximum softmax probability from the scaled cosine similarity output as the confidence score for OOD detection.
- Employs a single forward pass for inference, making it computationally efficient compared to methods requiring multiple forward passes or gradient computation.
- Introduces a specific scaling mechanism (temperature scaling) and normalization strategy that differ from standard metric learning, enhancing OOD discrimination.
Experimental results
Research questions
- RQ1Can a deep learning-based OOD detection method achieve high performance without requiring hyperparameters tuned on OOD data?
- RQ2How does the proposed method based on scaled cosine similarity compare to existing OOD detection methods in terms of robustness to hyperparameter choice?
- RQ3Does the use of softmax on scaled cosine similarity improve OOD detection performance compared to standard logits or unnormalized cosine similarity?
- RQ4Can the method maintain competitive in-distribution accuracy while significantly improving OOD detection under realistic assumptions?
- RQ5How does the method perform on a benchmark that explicitly evaluates hyperparameter sensitivity, such as the one proposed by Shafaei et al.?
Key findings
- The proposed method outperforms all existing OOD detection methods on the Shafaei et al. benchmark, which evaluates hyperparameter robustness, achieving a significant margin in AUC scores.
- On the conventional OOD detection benchmark, the method achieves at least comparable performance to state-of-the-art methods, with AUC scores consistently above 97% on CIFAR-10 and CIFAR-100 with various OOD datasets.
- The method achieves 99.77% AUC on CIFAR-10 with TinyImageNet (cropped) OOD data using a Wide ResNet-28-10, outperforming ODIN and Mahalanobis detectors.
- The method is insensitive to the presence of a black frame in OOD datasets (e.g., in LSUN and TinyImageNet), while other methods show significant performance drops, indicating robustness to dataset artifacts.
- The method maintains high efficiency, requiring only a single forward pass, unlike methods such as ODIN or Leave-out Ensemble that require multiple forward passes with perturbations.
- The ablation study confirms that the specific scaling and normalization strategy in the proposed method are critical, as naive cosine similarity or unnormalized versions perform significantly worse.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.