Handling out-of-distribution (OOD) samples has become a major stake in the real-world deployment of machine learning systems. This work explores the use of self-supervised contrastive learning to the simultaneous detection of two types of OOD samples: unseen classes and adversarial perturbations. First, we pair self-supervised contrastive learning with the maximum mean discrepancy (MMD) two-sample test. This approach enables us to robustly test whether two independent sets of samples originate from the same distribution, and we demonstrate its effectiveness by discriminating between CIFAR-10 and CIFAR-10.1 with higher confidence than previous work. Motivated by this success, we introduce CADet (Contrastive Anomaly Detection), a novel method for OOD detection of single samples. CADet draws inspiration from MMD, but leverages the similarity between contrastive transformations of a same sample. CADet outperforms existing adversarial detection methods in identifying adversarially perturbed samples on ImageNet and achieves comparable performance to unseen label detection methods on two challenging benchmarks: ImageNet-O and iNaturalist. Significantly, CADet is fully self-supervised and requires neither labels for in-distribution samples nor access to OOD examples.
翻译:处理分布外样本已成为机器学习系统在实际部署中的关键挑战。本研究探索利用自监督对比学习同时检测两类分布外样本:未见类别与对抗扰动。首先,我们将自监督对比学习与最大均值差异(MMD)双样本检验相结合。该方法能够稳健地检验两组独立样本是否来自同一分布,我们通过以更高置信度区分CIFAR-10与CIFAR-10.1数据集证实了其有效性。基于此成果,我们提出CADet(对比异常检测)——一种针对单样本分布外检测的新方法。CADet借鉴MMD思想,利用同一样本的对比变换间的相似性。在ImageNet数据集上,CADet在识别对抗扰动样本方面超越现有对抗检测方法,并在两个具有挑战性的基准测试(ImageNet-O与iNaturalist)中达到与未见标签检测方法相当的性能。值得关注的是,CADet完全采用自监督方式,既无需训练数据的标签,也无需接触分布外样本。