Modern machine learning models deployed in the wild can encounter both covariate and semantic shifts, giving rise to the problems of out-of-distribution (OOD) generalization and OOD detection respectively. While both problems have received significant research attention lately, they have been pursued independently. This may not be surprising, since the two tasks have seemingly conflicting goals. This paper provides a new unified approach that is capable of simultaneously generalizing to covariate shifts while robustly detecting semantic shifts. We propose a margin-based learning framework that exploits freely available unlabeled data in the wild that captures the environmental test-time OOD distributions under both covariate and semantic shifts. We show both empirically and theoretically that the proposed margin constraint is the key to achieving both OOD generalization and detection. Extensive experiments show the superiority of our framework, outperforming competitive baselines that specialize in either OOD generalization or OOD detection. Code is publicly available at https://github.com/deeplearning-wisc/scone.
翻译:现代机器学习模型在开放环境中部署时,可能同时遭遇协变量偏移和语义偏移,分别引发分布外(OOD)泛化与OOD检测问题。尽管这两类问题近年来受到广泛研究关注,但相关工作一直独立推进——这或许不足为奇,因为两项任务看似目标相悖。本文提出一种全新统一方法,既能泛化到协变量偏移,又能鲁棒检测语义偏移。我们构建了一个基于间隔的学习框架,通过利用开放环境中可自由获取的无标签数据,捕获同时存在协变量偏移与语义偏移的环境测试时OOD分布。实验与理论分析均表明,所提出的间隔约束是实现OOD泛化与检测协同优化的关键。大量实验验证了我们框架的优越性,其性能超越了专注于OOD泛化或OOD检测的强基线方法。代码已开源:https://github.com/deeplearning-wisc/scone。