Unleashing Mask: Explore the Intrinsic Out-of-Distribution Detection Capability

Jianing Zhu, Hengzhuang Li, Jiangchao Yao, Tongliang Liu, Jianliang Xu, Bo Han

Introduction

Out-of-distribution (OOD) detection is a cornerstone of reliable machine learning, particularly in safety-critical applications like autonomous driving and medical diagnostics. A robust system must not only classify known categories accurately but also recognize when an input falls outside its training distribution—essentially knowing when to say "I don't know."

Conventional wisdom suggests that the best-performing model for OOD detection is the fully converged, final version of a neural network. However, this research challenges that assumption, revealing that neural networks actually possess superior OOD detection capabilities during their intermediate training stages. This paper introduces "Unleashing Mask" (UM), a method designed to recover this intrinsic OOD detection power by identifying and "forgetting" specific samples that degrade the model's performance in the late stages of training.

The Intermediate Stage Phenomenon

The authors observe a surprising trend: as training progresses, OOD detection performance (measured by metrics like FPR95) often peaks well before the model reaches its final convergence. While the model's accuracy on in-distribution (ID) test data continues to improve or stabilize, its ability to distinguish between ID and OOD data begins to deteriorate.

This degradation is attributed to the memorization of "atypical" training samples. These are semantically unusual ID samples that the model eventually learns to classify correctly by creating complex, overconfident decision boundaries. These boundaries often overlap with regions of the feature space occupied by OOD data, thereby blurring the distinction between the two and reducing the effectiveness of standard OOD scoring functions like Energy or ODIN.

Methodology: Unleashing Mask (UM)

To address this, the authors propose the Unleashing Mask (UM) framework, which aims to backtrack the model to its optimal OOD-detecting state without sacrificing the benefits of the original training.

1. Atypical Mining via Masking

The first challenge is identifying which samples are "atypical." The authors hypothesize that because these samples are learned late and are less representative of the general distribution, their classifications are highly sensitive to parameter perturbations. By applying a randomly initialized layer-wise mask—dropping a small percentage of weights—the authors can observe which samples the model suddenly misclassifies. These sensitive samples are flagged as atypical, and their loss values are used to estimate a target "forgetting" threshold.

2. Forgetting via Gradient Ascent

Once the atypical samples are identified, the UM method applies a constrained gradient ascent. This process deliberately increases the training loss for these specific samples until it reaches the estimated threshold. By forcing the model to "forget" these outliers, the decision boundaries are simplified, effectively reverting the model to a state where ID and OOD data are more clearly separated.

3. UM Adopts Pruning (UMAP)

While UM is effective, directly modifying weights can sometimes lead to a slight drop in standard ID accuracy. To mitigate this, the authors introduced UM Adopts Pruning (UMAP). Instead of altering the weights of the original model, UMAP learns a binary sub-network mask through pruning. This approach achieves the desired "forgetting" effect while keeping the original weights intact, thereby maintaining high ID accuracy while significantly boosting OOD detection performance.

Experimental Results

The effectiveness of UM and UMAP was evaluated across several benchmarks, including CIFAR-10, CIFAR-100, and ImageNet-1k, using OOD datasets such as Textures, Places365, and iNaturalist.

  • CIFAR Benchmarks: On CIFAR-10, using the Energy score as a baseline, UM reduced the False Positive Rate at 95% True Positive Rate (FPR95) from 42.69% to 33.29%. UMAP further improved this to 30.71% while maintaining an ID accuracy of approximately 94%.
  • Large-Scale Performance: On ImageNet, UMAP demonstrated significant scalability. When applied to the ODIN baseline, it reduced the average FPR95 across four OOD datasets from 51.29% to 40.94%.
  • Efficiency: The fine-tuning process for UM/UMAP is highly efficient, typically converging within 20 epochs. This makes it a practical post-hoc enhancement for pre-existing, fully trained models.

Conclusion

The "Unleashing Mask" framework provides a novel perspective on the relationship between model training and OOD detection. By recognizing that late-stage memorization of atypical samples is a hindrance rather than a help for OOD tasks, the authors demonstrate that "forgetting" can be a powerful tool for model robustness. This work opens new avenues for research into data pruning and the intrinsic properties of neural network representations, suggesting that the path to safer AI may involve strategically unlearning as much as learning.

Summary updated

BibTeX
@inproceedings{zhu2023unleashing,
  author = {Jianing Zhu and Hengzhuang Li and Jiangchao Yao and Tongliang Liu and Jianliang Xu and Bo Han},
  title = {{Unleashing Mask: Explore the Intrinsic Out-of-Distribution Detection Capability}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=9himkcdirP},
}
Figure