CADet: Fully Self-Supervised Out-Of-Distribution Detection With Contrastive Learning
About
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.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Error detection | Adversarial Attacks (test) | AUC70.02 | 40 | |
| OOD Detection | CoComageNet | Detection AUC0.5688 | 40 | |
| Error detection | In-distribution (test) | AUC0.565 | 40 | |
| Error detection | Corruptions (test) | AUC90.11 | 40 | |
| Error detection | Average All shifts (test) | AUC71.49 | 40 | |
| OOD Detection | CoComageNet mono | Detection AUC0.5224 | 40 | |
| Distribution Shift Detection | BROAD (test) | Novel Classes AUC66.79 | 40 | |
| OOD Detection | iNaturalist OOD | AUROC95.28 | 31 | |
| Distribution Shift Detection | CIFAR-10 vs CIFAR-10.1 | Average Rejection Rate1 | 27 | |
| OOD Detection | ImageNet-O | AUROC0.8229 | 18 |