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.
翻译:特征塑形是指一类在分布外(OOD)检测中展现最先进性能的方法。这些方法通常操控预训练深度学习模型倒数第二层的特征表示,以更好地区分分布内(ID)和OOD样本。然而,现有特征塑形方法通常采用针对特定模型架构和OOD数据集手动设计的规则,这限制了其泛化能力。针对这一不足,我们首先构建了一个用于研究特征塑形方法的抽象优化框架。随后我们提出该框架的一个具体简化,采用简单的分段常数塑形函数,并证明现有特征塑形方法近似于该具体优化问题的最优解。进一步,假设无法获取OOD数据,我们提出一个仅利用ID数据即可推导出分段常数塑形函数闭式解的公式。通过大量实验,我们证明经本文方法优化的特征塑形函数能够提升OOD检测在多种数据集和模型架构上的泛化能力。