Learning and Evaluating Representations for Deep One-Class Classification

Kihyuk Sohn, Chun-Liang Li, Jinsung Yoon, Minho Jin, Tomas Pfister

Introduction

One-class classification (OCC) is the task of identifying whether a new data point belongs to the same distribution as the training data. It serves as the backbone for critical applications like anomaly detection in manufacturing, fraud detection in finance, and novelty detection in computer vision.

This paper introduces a powerful two-stage framework for deep one-class classification. By decoupling representation learning from the classification task and introducing a novel "distribution-augmented contrastive learning" technique, the authors achieve state-of-the-art results while solving the common problem of "hypersphere collapse" in deep one-class models.

The Challenge of Deep One-Class Classification

The challenge with applying deep learning to OCC is two-fold. First, if you train a network to simply "describe" a single class, it often falls into a degenerate solution known as hypersphere collapse. The model maps every possible input to the exact same point, making it impossible to distinguish "normal" from "abnormal" data.

Second, while self-supervised learning (SSL) has revolutionized feature extraction, standard SSL objectives (like contrastive learning) are designed to spread representations out uniformly across a latent space. For OCC, we actually want the opposite: "normal" data should be tightly clustered so that anything falling outside that cluster is easily flagged as an anomaly.

A Two-Stage Methodology

To overcome these hurdles, the authors propose a clean, two-stage approach:

Two-stage framework for deep one-class classification
  1. Stage 1: Self-Supervised Representation Learning. Instead of training an end-to-end anomaly detector, the authors first train a deep feature extractor using self-supervised tasks. They specifically focus on Contrastive Learning but identify a critical flaw: it promotes "uniformity," which hurts anomaly detection. To fix this, they propose Distribution-Augmented Contrastive Learning (DistAug CL). By applying geometric transformations (like 90-degree rotations) and treating the rotated versions as different instances, the model is forced to distinguish between "normal" and "rotated-normal." This prevents the features from spreading out too much and creates a more compact representation of the target class.
  2. Stage 2: Shallow One-Class Classification. Once the features are learned, the network is "frozen." A simple, classical classifier is then built on top of these frozen representations, such as Kernel Density Estimation (KDE) or a One-Class SVM (OC-SVM).

Additionally, the authors provide a way to "see" what the model is thinking by using gradient-based explanation methods (like GradCAM) tied to the KDE normality score.

Key Insights and Ideas

  • Uniformity is the Enemy of Anomaly Detection: In standard contrastive learning (like SimCLR), the goal is to push different images as far apart as possible, creating a "uniform" distribution on a hypersphere. The authors show that this makes it nearly impossible to draw a boundary around "normal" data because there is no "empty space" left for anomalies to occupy.
Hypersphere feature distribution showing inliers, augmented data, and outliers
  • The Batch Size Paradox: While massive batch sizes are usually better for self-supervised learning, the authors found that moderate batch sizes (e.g., 32) actually perform better for OCC. Smaller batches reduce the pressure for perfect uniformity, allowing for the tighter clustering needed to spot outliers.
  • The Projection Head Matters: Features extracted before the final MLP projection head are much better for anomaly detection than features after it. The projection head tends to discard information that isn't strictly necessary for the proxy task (like rotation), but that discarded information is often vital for spotting anomalies.
  • Self-Supervision is Data-Efficient: The DistAug CL method could match the performance of a model pre-trained on the massive ImageNet dataset using only 100 examples from the target class.

Key Results

The framework was rigorously evaluated on several standard and specialized benchmarks, including CIFAR-10/100, Fashion-MNIST, Cat-vs-Dog, CelebA, and MVTec AD.

  • State-of-the-Art Performance: The proposed DistAug CL + KDE method achieved a mean AUC (Area Under the Curve) of 89.9% across five major benchmarks, significantly outperforming previous leaders like Deep SVDD (64.8% on CIFAR-10) and RotNet (86.6%).
  • Industrial Accuracy: On the MVTec AD real-world defect dataset, the model achieved 86.5% AUC for image-level detection and 90.4% for pixel-level localization of defects.
  • Interpretability: Visual explanations (heatmaps) confirmed that the model focuses on human-intuitive features—like the frames of eyeglasses or the specific location of a crack in a cable—rather than arbitrary background noise.

Limitations and Future Work

The authors noted that while their geometric-based transformations are highly effective for "semantic" anomalies (e.g., seeing a dog when you expect a cat), they are slightly less effective for purely "texture" based anomalies (e.g., a subtle discoloration on a piece of leather). Furthermore, while KDE and OC-SVM worked well for the second stage, the authors suggest that Gaussian Mixture Models (GMMs) might provide a better middle ground between the simplicity of a single Gaussian and the computational intensity of non-parametric KDE for very large datasets.

Summary updated

BibTeX
@inproceedings{sohn2021learning,
  author = {Kihyuk Sohn and Chun-Liang Li and Jinsung Yoon and Minho Jin and Tomas Pfister},
  title = {{Learning and Evaluating Representations for Deep One-Class Classification}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
  url = {https://openreview.net/forum?id=K93TnJH7Zt},
}
Figure