Out-Of-Distribution generalization (OOD) is all about learning invariance against environmental changes. If the context in every class is evenly distributed, OOD would be trivial because the context can be easily removed due to an underlying principle: class is invariant to context. However, collecting such a balanced dataset is impractical. Learning on imbalanced data makes the model bias to context and thus hurts OOD. Therefore, the key to OOD is context balance. We argue that the widely adopted assumption in prior work, the context bias can be directly annotated or estimated from biased class prediction, renders the context incomplete or even incorrect. In contrast, we point out the everoverlooked other side of the above principle: context is also invariant to class, which motivates us to consider the classes (which are already labeled) as the varying environments to resolve context bias (without context labels). We implement this idea by minimizing the contrastive loss of intra-class sample similarity while assuring this similarity to be invariant across all classes. On benchmarks with various context biases and domain gaps, we show that a simple re-weighting based classifier equipped with our context estimation achieves state-of-the-art performance. We provide the theoretical justifications in Appendix and codes on https://github.com/simpleshinobu/IRMCon.
翻译:分布外泛化(Out-Of-Distribution Generalization, OOD)的核心在于学习应对环境变化的不变性。若每个类别中的环境分布均匀,则OOD问题将迎刃而解——因为基于一个基本原则“类别对环境具有不变性”,环境因素可被轻易剔除。然而,采集此类平衡数据集并不现实。在不平衡数据上的学习会使模型偏向环境特征,进而损害OOD性能。因此,实现OOD的关键在于环境平衡。我们认为,此前研究广泛采用的假设——环境偏差可直接通过标注或从有偏类别预测中估计——会导致环境信息不完整甚至错误。相反,我们揭示了上述原则中常被忽视的另一面:环境对类别同样具有不变性。这启发我们将已有标注的类别作为变化的环境,以解决环境偏差(无需环境标签)。我们通过最小化同类样本间对比损失的类内相似度,并确保该相似度在所有类别中保持不变来实现这一思想。在包含多种环境偏差和领域差异的基准测试中,我们展示了基于简单重加权的分类器结合我们的环境估计方法,能够达到最先进的性能。理论证明详见附录,代码已开源至 https://github.com/simpleshinobu/IRMCon。