NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Safer Classification by Synthesis.

William Wang, Angelina Wang, Aviv Tamar, Xi Chen, Pieter Abbeel

TL;DR

Standard deep neural networks are easily fooled by out-of-distribution (OOD) data, often assigning incorrect labels with dangerously high confidence. This paper introduces "Classification by Synthesis," an alternative paradigm that trains generative models (like GANs or VAEs) for each class and classifies new inputs based on which generator can best reconstruct them. This approach allows the model to inherently "know when it doesn't know," providing a reliable defense against out-of-distribution errors.

What Problem Does This Paper Address?

The dominant paradigm in computer vision is discriminative classification: a deep network draws decision boundaries to separate classes and maps an input image to a probability distribution. While highly accurate, these models suffer from a critical safety flaw: they don't actually understand what makes a class unique; they only know how to separate it from others.

Consequently, when presented with out-of-distribution (OOD) data—samples completely foreign to the training set—discriminative models often misclassify them with near-100% confidence. For safety-critical applications like self-driving cars, this is unacceptable. A car trained only on road signs should abstain or flag an anomaly when it encounters an elephant, rather than confidently misclassifying it as a stop sign.

The authors address this gap by leveraging selective classification, where a model can choose to abstain from making a prediction if its confidence falls below a certain threshold.

Methods

The authors propose a generative approach to classification, termed Classification by Synthesis.

  1. Training: Instead of training one massive network to separate all classes, they train an independent generative model $G_k(z)$ (such as a VAE or a GAN) for each individual class $k$. Each generator learns the underlying data manifold for its specific class.
  2. Inference: When a test image $x$ arrives, the system queries every class generator to find the latent vector $z$ that produces the most similar image to $x$. This is formulated as an optimization problem using the negative $L_2$ distance as the similarity measure $s$: $$z^*_k = \arg\max_z s(x, G_k(z))$$
  3. Classification: The image is assigned to the class whose generator achieved the highest reconstruction similarity.
  4. Selective Thresholding: The maximum similarity score serves as a natural confidence metric. If no generator can accurately reconstruct the input image, the system safely abstains from predicting.

To solve the non-convex optimization problem during inference, the authors use Monte Carlo sampling followed by L-BFGS refinement. For VAEs, they pass the image through the encoder network to efficiently initialize the latent vector.

Datasets

  • MNIST: The standard dataset of handwritten digits (0-9), used as the in-distribution training and testing data.
  • Omniglot: A dataset containing handwritten characters from 50 different alphabets. This was used entirely as out-of-distribution (OOD) data. The authors resized the images to 28x28 and removed ambiguous characters that naturally resembled digits to ensure a clean evaluation.

Key Insights and Ideas

  • The Decision Boundary Trap: As illustrated in the paper's conceptual diagram, discriminative models define confidence based on the distance from a decision boundary. An OOD sample can be wildly different from the training data but still lie deep within a class's territory, triggering a high-confidence error.
Figure 5: An illustration of an out-of-distribution example with a discriminative classifier. Here, a classifier discriminates between the square and circle examples. We can relate the confidence of the classifier with the distance to the decision boundary. As shown, an out-of-distribution example that is far away from this boundary will be classified with a high confidence to belong, in this case, to the class of circles.
  • The Vanishing Risk Property: A trustworthy selective classifier should exhibit "vanishing risk"—meaning its error rate should drop to zero as the confidence threshold is raised. Standard CNNs fail this on OOD data because they assign maximum confidence to completely foreign images. Generative classifiers preserve this property because a generator cannot synthesize an image structure it has never seen before.
  • Interpretability by Design: This paradigm provides immediate, visual explanations. If the model classifies an ambiguous shape as a '5', you can inspect the exact image the '5'-generator synthesized to see why it matched.

Key Results

The authors evaluated their method on an augmented dataset consisting of 24% MNIST digits and 76% Omniglot characters.

  • The Discriminative Failure: A standard CNN achieved a minimum risk of 0.061 even at its maximum confidence threshold, meaning it confidently misclassified hundreds of Omniglot characters as digits.
  • Generative Success: The generative classifier successfully drove the classification risk down to zero as selectivity increased, proving its confidence metric accurately flags OOD data.
  • The Hybrid Solution: Because generative models have slightly lower baseline accuracy on clean data (97.81% for DCGAN vs. >99% for state-of-the-art CNNs), the authors introduced a hybrid approach. They used the generative classifier as a novelty detector to filter out OOD data, and passed the accepted images to a standard CNN for final classification. This achieved the best of both worlds: top-tier accuracy on in-distribution data alongside perfect resilience to OOD examples.

Limitations and Future Work

  • Computational Cost: Finding the optimal latent vector $z^*$ requires solving an iterative optimization problem at test time. This is significantly slower than the single forward pass required by a standard discriminative CNN.
  • Generator Degeneracies: If a generator is overly expressive, it might accidentally synthesize an image from a different class. For instance, the '8' generator might successfully draw a '5', causing a misclassification.
  • Scaling to Complex Data: The experiments were limited to simple, grayscale datasets (MNIST and Omniglot). Scaling classification by synthesis to complex, high-resolution natural images (like ImageNet) remains an open challenge due to the difficulties of training high-fidelity generative models on complex scenes.

Summary updated

BibTeX
@misc{wang2017safer,
  author = {William Wang and Angelina Wang and Aviv Tamar and Xi Chen and Pieter Abbeel},
  title = {{Safer Classification by Synthesis.}},
  year = {2017},
  eprint = {1711.08534},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1711.08534},
}
Figure