Variational Classification

Shehzaad Zuzar Dhuliawala, Mrinmaya Sachan, Carl AllenUniReps @ NeurIPS 2023

TL;DR

This paper introduces Variational Classification (VC), a novel probabilistic framework that generalizes standard softmax classification. VC offers a more principled interpretation of neural network classifiers, leading to improved calibration, robustness to distribution shifts and adversarial attacks, and better performance in low-data regimes, all with minimal computational overhead.

What Problem Does This Paper Address?

Standard neural network classifiers often rely on the softmax output layer, which, while effective, suffers from several well-known issues. These include a lack of theoretical understanding (making them "black boxes"), susceptibility to adversarial perturbations, poor calibration (overconfidence in predictions), and a significant need for large amounts of training data. The authors aim to address these limitations by providing a more robust and interpretable probabilistic foundation for classification.

Methods

The core contribution is Variational Classification (VC), which frames classification as a latent variable model. This is analogous to the relationship between deterministic and variational autoencoders. Instead of a direct mapping from input to class probabilities, VC introduces a latent variable z that captures intermediate representations.

Key aspects of the VC method include:

  • Probabilistic Interpretation: VC reinterprets the components of a softmax classifier probabilistically. The neural network (before the softmax layer) maps data to a distribution in a latent space, and the softmax layer then uses Bayes' rule to derive class predictions.
  • Latent Variable Model: VC utilizes a generative latent variable model p(x, y) = ∫ p(x|z)p(z|y)p(y) dz dy.
  • Evidence Lower Bound (ELBO): The training objective is based on maximizing a variant of the ELBO, which is non-trivial to optimize.
  • Adversarial Training: An adversarial approach is employed to maximize the ELBO.
  • Flexible Latent Distributions: Unlike standard softmax, VC allows for flexible choices of distributions in the latent space, moving beyond implicit assumptions.
  • Alignment of Distributions: The objective function encourages alignment between anticipated class-conditional latent distributions (p(z|y)) and empirical ones (q(z|y)), achieved by minimizing KL divergence.
  • Auxiliary Objective: An auxiliary objective is used to estimate log ratios for optimization, making the process more tractable.

Datasets

The paper evaluates VC on several standard datasets:

  • Image Classification: CIFAR-10, CIFAR-100, Tiny-ImageNet, MNIST, MedMNIST.
  • Natural Language Inference: SNLI and MNLI datasets.
  • Medical Imaging: CAMELYON17 dataset.

The paper also uses corrupted versions of image datasets (CIFAR-10-C, CIFAR-100-C, Tiny-ImageNet-C) to simulate distribution shifts.

Key Insights and Ideas

  • Softmax as a Special Case: The paper reveals that standard softmax classification can be viewed as a specific, highly constrained instance of Variational Classification, where the latent distribution is a delta function. This highlights the implicit assumptions made by traditional softmax.
  • Inconsistency in Softmax: VC exposes an inherent inconsistency in standard softmax where the latent distribution expected by the softmax layer might not align with the distribution learned by the preceding layers. VC's objective directly addresses this.
  • Improved Calibration: By introducing a more structured latent space and probabilistic interpretation, VC significantly improves model calibration, meaning its confidence in predictions better reflects actual accuracy.
  • Benefits of Latent Structure: The introduction of latent variables and flexible distributions in VC demonstrably enhances robustness to distribution shifts and adversarial attacks, and crucially, improves performance in low-data regimes.
  • Principled Merging of Learning Paradigms: VC offers a framework to potentially merge supervised learning with other representation learning methods (like contrastive learning) by using a common encoder architecture.

Key Results

  • Accuracy Maintained: VC achieves classification accuracy comparable to standard softmax (CE) across various datasets.
  • Improved Calibration: Expected Calibration Error (ECE) is notably reduced by VC, especially under distribution shift and in low-data settings. For example, on CAMELYON17, VC reduced ECE from 8.4 to 1.8.
  • Adversarial Robustness: VC shows consistently higher accuracy than CE and GM (a MAP-like approach) under increasing FGSM adversarial attack magnitudes on MNIST and CIFAR-10.
  • Low Data Performance: VC significantly outperforms CE and GM in low-data regimes, particularly on complex datasets like AGNEWS, suggesting the latent prior helps generalization. For instance, on AGNEWS with 500 samples, VC achieved 66.3% accuracy compared to CE's 56.3%.
  • Distribution Shift Resilience: VC performs comparably well to CE under synthetic distribution shifts, and shows improved calibration on natural distribution shifts.

Limitations and Future Work

  • Focus on Last Layer: The current VC framework primarily focuses on the last layer of a classifier, treating preceding layers as a "black box." The authors acknowledge that understanding and improving how these earlier layers transform data distributions into latent distributions remains an open question.
  • Computational Overhead: While the paper states minimal overhead, optimizing the ELBO and using adversarial training can introduce computational costs, though empirical results suggest it's manageable.
  • Defining OOD: The paper notes that "OOD" is a loosely defined term, and while VC shows promise, it doesn't necessarily outperform standard CE in distinguishing OOD samples using the tested metrics.
  • Future Directions: The authors suggest exploring how the underlying network architecture can be better optimized to contribute to the VC framework and investigating the principled merging of VC with other representation learning techniques.

Summary updated

BibTeX
@inproceedings{dhuliawala2023variational,
  author = {Shehzaad Zuzar Dhuliawala and Mrinmaya Sachan and Carl Allen},
  title = {{Variational Classification}},
  booktitle = {UniReps @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=FO646rF6MM},
}
Figure