Out-of-Distribution (OOD) detection is a crucial problem for the safe deployment of machine learning models identifying samples that fall outside of the training distribution, i.e. in-distribution data (ID). Most OOD works focus on the classification models trained with Cross Entropy (CE) and attempt to fix its inherent issues. In this work we leverage powerful representation learned with Supervised Contrastive (SupCon) training and propose a holistic approach to learn a classifier robust to OOD data. We extend SupCon loss with two additional contrast terms. The first term pushes auxiliary OOD representations away from ID representations without imposing any constraints on similarities among auxiliary data. The second term pushes OOD features far from the existing class prototypes, while pushing ID representations closer to their corresponding class prototype. When auxiliary OOD data is not available, we propose feature mixing techniques to efficiently generate pseudo-OOD features. Our solution is simple and efficient and acts as a natural extension of the closed-set supervised contrastive representation learning. We compare against different OOD detection methods on the common benchmarks and show state-of-the-art results.
翻译:分布外检测是机器学习模型安全部署中的关键问题,旨在识别偏离训练分布的样本(即分布内数据)。现有分布外检测工作主要聚焦于交叉熵训练的分类模型,并尝试修正其固有缺陷。本文利用监督对比训练习得的强表征能力,提出一种面向分布外数据鲁棒分类器的整体性学习方案。我们将监督对比损失扩展为包含两个对比项:第一项强制辅助分布外表征远离分布内表征,同时不对辅助数据间的相似性施加任何约束;第二项推动分布外特征远离现有类别原型,同时促使分布内表征向其对应的类别原型聚拢。当缺乏辅助分布外数据时,我们提出特征混合技术高效生成伪分布外特征。该方案简洁高效,是闭集监督对比表征学习的自然扩展。我们在通用基准上对比多种分布外检测方法,取得了最优结果。