Source-linked AI summary

Learning and Evaluating Representations for Deep One-class Classification

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

arXiv:2011.02578v2cs.CV

TL;DR

One-class classification needs representations that capture inlier structure without access to anomaly examples, while existing deep approaches can suffer from collapse or task-misaligned surrogate classifiers. The paper separates self-supervised representation learning from one-class classifier construction, introduces distribution-augmented contrastive learning, and reports strong performance on visual benchmarks. It also examines classifier choice and provides visual explanations of the resulting decisions.

  • Problem

    One-class classification is fundamentally limited by the challenge of learning good high-level representations, and naive deep training can cause hypersphere collapse.

  • Method

    A two-stage framework learns self-supervised representations from one-class data, then applies one-class classifiers such as KDE or OC-SVM to those representations.

  • Results

    Distribution-augmented contrastive learning achieves the highest mean AUC of 89.9 among the evaluated methods, with gains on all datasets over vanilla counterparts.

  • Takeaways & Limitations

    Decoupling representation learning from classifier construction enables task-consistent one-class detectors and supports strong performance on visual one-class benchmarks.

  • Takeaways & Limitations

    Rotation-based normality scores assume inlier images are not rotated and may fail to generalize when the proxy task is overfit.

Abstract

from arXiv · show

We present a two-stage framework for deep one-class classification. We first learn self-supervised representations from one-class data, and then build one-class classifiers on learned representations. The framework not only allows to learn better representations, but also permits building one-class classifiers that are faithful to the target task. We argue that classifiers inspired by the statistical perspective in generative or discriminative models are more effective than existing approaches, such as a normality score from a surrogate classifier. We thoroughly evaluate different self-supervised representation learning algorithms under the proposed framework for one-class classification. Moreover, we present a novel distribution-augmented contrastive learning that extends training distributions via data augmentation to obstruct the uniformity of contrastive representations. In experiments, we demonstrate state-of-the-art performance on visual domain one-class classification benchmarks, including novelty and anomaly detection. Finally, we present visual explanations, confirming that the decision-making process of deep one-class classifiers is intuitive to humans. The code is available at https://github.com/google-research/deep_representation_one_class.

1 INTRODUCTION

One-class classification depends critically on learning useful high-level representations, yet naive deep training can collapse representations. The paper addresses this with a two-stage framework that separates self-supervised representation learning from task-faithful one-class classifier construction.

  • One-class classification identifies whether examples belong to the training distribution and supports applications such as anomaly, fraud, and defect detection.
  • High-dimensional density estimation is difficult, while discriminative one-class methods remain limited by the quality of input representations.
  • Naive deep one-class training can produce hypersphere collapse, motivating architectural constraints, pretraining, simulated outliers, or injected noise.
  • The proposed framework first learns representations from one-class data with self-supervised methods, then trains classifiers such as OC-SVM or KDE on those representations.
  • The study evaluates augmentation prediction, contrastive learning, and distribution-augmented contrastive learning, reporting strong results across visual one-class benchmarks.

2 RELATED WORK

Prior work uses generative, discriminative, and self-supervised methods for one-class classification, but learned representations and detector choices remain central concerns. This paper studies representation learning systematically and pairs learned inlier representations with simple one-class classifiers.

  • One-class classification has applications including fraud detection, spam filtering, medical diagnosis, and manufacturing defect detection, often using unlabeled data.
  • Self-supervised learning learns representations from unlabeled data through proxy tasks such as rotation prediction, clustering, instance discrimination, and contrastive learning.
  • The framework compares self-supervised representations with simple one-class classifiers, including KDE and OC-SVM, rather than relying only on augmentation classifiers.
  • Simple one-class classifiers consistently improve performance, and the paper proposes strategies for better representation learning in augmentation prediction and contrastive learning.
  • Distribution-augmented contrastive learning is motivated as a way to reduce contrastive-representation uniformity, while the study also emphasizes detection algorithms.

3 A TWO-STAGE FRAMEWORK FOR DEEP ONE-CLASS CLASSIFICATION

The framework separates self-supervised representation learning from one-class classifier construction, then addresses representation problems that make contrastive learning unsuitable for one-class data. It uses projection heads, augmentation-based objectives, distribution augmentation, and KDE or OC-SVM classifiers to obtain representations and decision rules aligned with one-class classification.

  • 3.1.1 EXTRACTING RICHER REPRESENTATION BY LEARNING WITH PROJECTION HEAD: Projection-head training lets the feature extractor provide downstream representations while the head computes the proxy loss.The identity choice g(x) = x recovers the network structure used in earlier augmentation-prediction approaches.
  • 3.1.2 AUGMENTATION PREDICTION: Rotation prediction learns representations by predicting augmentation degrees, but its normality score assumes inlier images are not rotated and may overfit the proxy task.The rotation target uses four degrees, y ∈ {0, 1, 2, 3}, corresponding to repeated 90-degree rotations.
  • 3.1.3 CONTRASTIVE LEARNING: Contrastive learning can cause class collision and excessive uniformity, separating same-class instances and making outliers difficult to isolate on the hypersphere.Reduced uniformity makes the inlier–outlier boundary clearer, whereas perfect uniformity places inliers near arbitrary outliers.
  • 3.1.3 CONTRASTIVE LEARNING: Distribution augmentation models a union of augmented training distributions, treating transformed instances as separate examples to obstruct uniformity and compact the inlier distribution.Geometric transformations such as rotation or horizontal flip are used for distribution augmentation, distinct from the view-generating augmentations in contrastive learning.
  • 3 A TWO-STAGE FRAMEWORK FOR DEEP ONE-CLASS CLASSIFICATION: The framework first learns representations with self-supervised objectives and then trains shallow one-class classifiers such as OC-SVM or KDE on them.This decoupling makes classifier construction more faithful to the one-class objective and allows different representations to be evaluated independently.
  • 3.2 BUILDING DEEP ONE-CLASS CLASSIFIERS WITH LEARNED REPRESENTATIONS: KDE estimates densities and OC-SVM describes support directly in the learned representation space, providing generative and discriminative classifier options.The methods use the full distribution of learned representations rather than relying solely on a surrogate classifier score.

4 EXPERIMENTS

Experiments evaluate self-supervised representations and shallow one-class classifiers across visual benchmarks, finding strong gains from separating representation learning from detection and from distribution-augmented contrastive learning.

  • Evaluation setup: The study evaluates unsupervised and self-supervised representations with OC-SVM and KDE on CIFAR-10, CIFAR-100, Fashion-MNIST, Cat-vs-Dog, CelebA eyeglasses, and MVTec.MVTec additionally measures image-level detection and pixel-level localization.
  • Main results: 84.0 mean AUC over 5 datasets is achieved by ImageNet pretrained ResNet-50, the strongest reported performance for that comparison.The authors attribute especially strong results on CIFAR-100, cat-vs-dog, and CelebA to related ImageNet classes.
  • Main results: 88.2 AUC is obtained by the RotNet representation with an MLP projection head, versus 83.1 AUC for the end-to-end RotNet classifier and 86.6 for RotNet with KDE.This comparison highlights the effect of using a separate detector and projection-head training.
  • Main results: 89.9 mean AUC is achieved by distribution-augmented contrastive learning, exceeding vanilla contrastive learning’s 86.9 AUC with OC-SVM across the evaluated datasets.The reported distribution-augmented method improves performance on all datasets by a large margin over its vanilla counterpart.
  • Comparison to prior work: The framework advances previous state-of-the-art one-class classification benchmarks by a large margin without test-time augmentation or model ensembles.Model ensembling provides an additional improvement reported in the appendix.
  • MVTec defect detection: On MVTec, distribution-augmented contrastive learning improves vanilla contrastive learning, while RotNet with KDE significantly outperforms RotNet with its built-in rotation classifier.The evaluation reports both detection and localization AUCs.

5 ANALYSIS AND ABLATION STUDY

The analyses examine uniformity, batch size, projection heads, distribution augmentation, anomaly settings, and visual explanations to identify design choices affecting one-class performance and interpretability.

  • Uniformity, batch size and distribution augmentation: Contrastive-learning analyses relate representation uniformity to one-class performance and investigate batch size, MLP heads, and distribution-augmented contrastive learning.Uniformity is measured by MMD distance to samples from uniform distributions on hyperspheres.
  • Uniformity, batch size and distribution augmentation: Distribution augmentation makes contrastive representations less uniform and produces a significant one-class classification gain compared with standard contrastive learning.The standard representation becomes only slightly better than random guessing at near-uniformity.
  • Uniformity, batch size and distribution augmentation: Larger batch sizes make standard contrastive representations more uniform, which is harmful for one-class classification, while batch size 32 gives the best performance.Small batch sizes of 16 or fewer hinder useful representation learning through information maximization.
  • MLP projection heads: The pre-projection representation f improves with deeper MLP heads, whereas the projection output g◦f degrades because it overfits the proxy task.Removing any of the analyzed components causes an AUC drop.
  • Different distribution augmentations: On CIFAR-10, adding horizontal flip raises AUC to 90.7, while accumulating hflip, rot90, and rot90+hflip reaches a best mean AUC of 93.7 without test-time augmentation.The results show that the choice of augmented distributions affects performance.
  • Visual explanations: Visual explanations from the KDE one-class classifier highlight meaningful regions such as dog faces or eyeglasses, unlike some rotation-classifier explanations that rely on spurious background features.On cat-vs-dog, the cited AUCs are 89.6 for the proposed approach and 86.1 for the rotation classifier.

6 CONCLUSION

The paper concludes that decoupling representation learning from one-class classifier construction enables task-consistent classifiers and strong visual one-class classification. It also finds that simple Gaussian density estimation can competitively model the learned representations, while its assumptions limit universal use.

  • 6 CONCLUSION: The two-stage framework separates self-supervised representation learning from one-class classifier construction, supporting classifiers consistent with the target task.It uses learned representations with classifiers such as OC-SVM or KDE rather than surrogate losses.
  • 6 CONCLUSION: Good learned representations allow both discriminative OC-SVM and generative KDE classifiers to achieve competitive one-class classification performance.The paper emphasizes that the framework supports multiple self-supervised representation learning methods and classifier families.
  • 6 CONCLUSION: OC-SVM, KDE, and related statistical classifiers provide the framework’s generative and discriminative classifier choices.The formulations include OC-SVM and kernel density estimation, with linear and RBF kernels used in experiments.
  • 6 CONCLUSION: Gaussian density estimation performs competitively with KDE, suggesting that distribution-augmented contrastive representations can be approximated by a single Gaussian.The paper notes that this data-efficient parametric model depends on assumptions about the underlying distribution.
  • 6 CONCLUSION: A single Gaussian is not universally a substitute for KDE because parametric assumptions trade model flexibility against data efficiency and computational efficiency.The paper identifies Gaussian mixture models as a possible middle ground and leaves their study for future work.

A.2.2 ANALYSIS ON DISTRIBUTION AUGMENTED CONTRASTIVE REPRESENTATIONS

The analysis connects distribution augmentation, contrastive-representation uniformity, and classifier ensembling. Lower uniformity is associated with better one-class classification, while ensembles improve performance beyond single representations.

  • Relation to Outlier Exposure: Distribution augmentation introduces new training distributions without requiring the non-overlap assumption imposed by outlier exposure.Both approaches add distributions, but outlier exposure assumes introduced outliers do not overlap with inliers.
  • Ensemble of Contrastive Representations: Ensembling classifiers built on different representations significantly improves performance, whereas test-time augmentation yields only marginal improvement.The framework already achieves state-of-the-art one-class classification performance without test-time augmentation.
  • Correlation between Uniformity and One-class Classification: More uniformly distributed contrastive representations correspond to worse one-class classification performance, and reducing uniformity of g ◦f improves accuracy for both evaluated outputs.The analysis reports this pattern for vanilla and distribution-augmented contrastive representations across multiple batch sizes and random seeds.
  • Correlation between Uniformity and One-class Classification: AUC is positively correlated with representation uniformity measured by log(MMD), with Pearson correlations of 0.914 and 0.774 across the evaluated representation outputs.The first correlation evaluates MMD and AUC using g ◦f; the second uses MMD from g ◦f and AUC from f.

A.2.3 DATA EFFICIENCY OF SELF-SUPERVISED REPRESENTATION LEARNING

The paper studies whether self-supervised representations remain useful when one-class data are scarce. Its results show benefits even when representation learning uses only 50 examples.

  • Motivation: Data efficiency is especially important for one-class representation learning because large-scale data are difficult to collect even without annotations.The paper contrasts this setting with multi-class learning, where data requirements may scale with the number of classes.
  • Results: Even with 50 examples, classifiers benefit from self-supervised representations compared with the evaluated baseline representations.Representation-learning set sizes range from 50 to 5000, while classifiers use a fixed 5000-example set for fair representation evaluation.

A.3 UNSUPERVISED AND SEMI-SUPERVISED ANOMALY DETECTION

The experiments examine anomaly detection when training data include unlabeled outliers or when classifiers receive only a small labeled inlier subset. Outlier contamination degrades deep one-class classifiers, while contrastive representations can improve under the latter semi-supervised setting.

  • Unsupervised anomaly detection: Unsupervised anomaly detection includes both inlier and outlier training examples without labels, unlike one-class classification, which assumes entirely inlier training data.The experiments vary the proportion of unlabeled outliers while keeping the total training-set size unchanged.
  • Unsupervised anomaly detection: Outlier contamination at 0.5%, 1%, 2%, 5%, or 10% degrades deep one-class classifier performance across the evaluated representation models.The evaluated models include rotation prediction, contrastive learning, and distribution-augmented contrastive learning.
  • Unsupervised anomaly detection: The experiments evaluate OC-SVM with RBF and linear kernels together with Gaussian density estimation under unsupervised training conditions.Figure 10 compares classifier performance across representations trained with different outlier ratios.
  • Semi-supervised anomaly detection: In the semi-supervised setting, representations learn from unlabeled mixed data while classifiers train on a small amount of labeled inlier data.This setting is motivated as realistic because labeled inliers may be easier to obtain than outliers.
  • Semi-supervised anomaly detection: Contrastive representations trained with higher outlier proportions consistently improve classification when the classifier is trained on pure one-class data.The proposed framework is applied without modification in this experiment.

A.4 DETAILS OF EXPERIMENTAL SETTING

Experiments evaluate one-class classification and localization across image and patch-based settings, using fixed preprocessing, optimization, and detector configurations. MVTec experiments address limited training data through patch representations and assess both image-level detection and pixel-level localization.

  • General setup: Images are resized to 64×64 for Cat-vs-Dog and CelebA, and to 32×32 for the remaining datasets.Unless otherwise stated, models use 2048 epochs of momentum-SGD, cosine learning-rate decay, and L2 regularization with coefficient 0.0003.
  • General setup: Hyperparameters are cross-validated using 10% of CIFAR-10 inliers and an equal number of outliers, then reused to test methods.The authors note that supervised model selection may violate the one-class assumption but is used because deep-learning behavior depends on hyperparameters.
  • MVTec setup: MVTec contains 15 categories, with approximately 241 normal training images and 115 mixed normal/defective test images per category.The dataset includes pixel-accurate annotations for defective regions.
  • MVTec setup: Because MVTec training sets are small, representations are learned from 32×32 patches rather than holistic images.Images are resized to 256×256, and self-supervised representation performance degrades when training data is limited.
  • MVTec evaluation: MVTec evaluation reports image-level detection AUC and pixel-level localization AUC from dense patch embeddings and KDE anomaly scores.A 57×57 score map is spatially max-pooled for detection and upsampled to 256×256 for localization.

B.3 EXPERIMENTAL RESULTS

The proposed two-stage framework outperforms an end-to-end RotNet classifier, while an MLP projection head and distribution augmentation further improve representations. Results also show stronger performance for object than texture categories.

  • Main results: The two-stage RotNet-plus-one-class-classifier framework clearly outperforms end-to-end RotNet with its built-in rotation classifier.The comparison uses the MVTec anomaly-detection setting described in the surrounding experimental results.
  • Main results: Adding an MLP projection head further improves RotNet representations for one-class classification.The enhanced representation is evaluated with the proposed KDE detector.
  • Representation learning: Distribution augmentation through rotation improves the performance of contrastive representations.The augmentation extends the training distribution used for contrastive learning.
  • MVTec results: The proposed method improves localization AUC over [76] in both detection and localization, across object and texture categories.Table 12 reports means and standard deviations over five random seeds, with results averaged across category groups.
  • Category differences: RotNet and contrastive representations are effective for object categories but less effective for texture categories.The authors relate this pattern to the differing demands of semantic and texture anomaly detection.

B.4 QUALITATIVE RESULTS ON LOCALIZATION

Qualitative visualizations inspect explanations and defect localization across multiple datasets and MVTec categories. The figures compare inputs with attribution heatmaps or with ground-truth masks and localization heatmaps.

  • Defect localization: MVTec bottle, cable, capsule, screw, transistor, grid, and leather figures show defective inputs, ground-truth masks, and heatmap-based localization visualizations.The representations are trained with rotation prediction on patches.
  • Defect localization: The MVTec qualitative figures use the same left-to-right comparison for bottle, cable, capsule, screw, transistor, grid, and leather categories.Each visualization places defective test inputs alongside the annotated defect region and predicted localization heatmap.
Loading 2011.02578v2…