Towards Optimal Feature-Shaping Methods for Out-of-Distribution Detection
Qinyu Zhao, Ming Xu, Kartik Gupta, Akshay Asthana, Liang Zheng, Stephen Gould
Abstract
Feature shaping refers to a family of methods that exhibit state-of-the-art performance for out-of-distribution (OOD) detection. These approaches manipulate the feature representation, typically from the penultimate layer of a pre-trained deep learning model, so as to better differentiate between in-distribution (ID) and OOD samples. However, existing feature-shaping methods usually employ rules manually designed for specific model architectures and OOD datasets, which consequently limit their generalization ability. To address this gap, we first formulate an abstract optimization framework for studying feature-shaping methods. We then propose a concrete reduction of the framework with a simple piecewise constant shaping function and show that existing feature-shaping methods approximate the optimal solution to the concrete optimization problem. Further, assuming that OOD data is inaccessible, we propose a formulation that yields a closed-form solution for the piecewise constant shaping function, utilizing solely the ID data. Through extensive experiments, we show that the feature-shaping function optimized by our method improves the generalization ability of OOD detection across a large variety of datasets and model architectures. 1
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers8
- Learning to Shape In-distribution Feature Space for Out-of-distribution DetectionYonggang Zhang, Jie Lu, Bo Peng, Zhen Fang et al.NeurIPS 2024 · 33 citations
- AdaSCALE: Adaptive Scaling for OOD DetectionSudarshan RegmiICML 2026 · 9 citations
- Diffusion-based Layer-wise Semantic Reconstruction for Unsupervised Out-of-Distribution DetectionYing Yang, De Cheng, Chaowei Fang, Yubiao Wang et al.NeurIPS 2024 · 9 citations
- A Geometry-Based View of Mahalanobis OOD DetectionDenis Janiak, Jakub Binkowski, Tomasz KajdanowiczICML 2026 · 3 citations
- DCAC: Dynamic Class-Aware Cache Creates Stronger Out-of-Distribution DetectorsYanqi Wu, Qichao Chen, Runhe Lai, Xinhua Lu et al.AAAI 2026 · 1 citation
Builds on13
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu et al.ICCV 2021 · 31,683 citations
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
- MLP-Mixer: An all-MLP Architecture for VisionIlya O. Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer et al.NeurIPS 2021 · 3,862 citations
- Energy-based Out-of-distribution DetectionWeitang Liu, Xiaoyun Wang, John D. Owens, Yixuan LiNeurIPS 2020 · 2,213 citations
- ReAct: Out-of-distribution Detection With Rectified ActivationsYiyou Sun, Chuan Guo, Yixuan LiNeurIPS 2021 · 733 citations
Related papers
- A Variational Information Theoretic Approach to Out-of-Distribution DetectionSudeepta Mondal, Zhuolin Jiang, Ganesh SundaramoorthiICML 2025
- Watermarking for Out-of-distribution DetectionQizhou Wang, Feng Liu, Yonggang Zhang, Jing Zhang et al.NeurIPS 2022 · 44 citations
- Extremely Simple Activation Shaping for Out-of-Distribution DetectionAndrija Djurisic, Nebojsa Bozanic, Arjun Ashok, Rosanne LiuICLR 2023 · 23 citations
- Scaling for Training Time and Post-hoc Out-of-distribution Detection EnhancementKai Xu, Rongyu Chen, Gianni Franchi, Angela YaoICLR 2024 · 81 citations
- Activation Subspaces for Out-of-Distribution DetectionBaris Zöngür, Robin Hesse, Stefan RothICCV 2025 · 2 citations
