Variational Classification
Shehzaad Dhuliawala, Mrinmaya Sachan, Carl Allen
TL;DR
This work reframes standard softmax classification as a latent-variable model and introduces Variational Classification (VC), a probabilistic objective that aligns empirical latent distributions with a chosen anticipated distribution via an ELBO-like training objective. By treating the softmax input as a latent variable and using an encoder to model $q_\phi(z|x)$ and a Bayes-rule output layer $p_\theta(y|z)$, VC generalises cross-entropy and enables explicit control over latent priors and distributions. Empirically, VC achieves comparable accuracy to traditional softmax while substantially improving calibration, adversarial robustness, distribution-shift resilience, and sample efficiency in low-data settings, with minimal overhead and no extra hyperparameter tuning. The approach provides theoretical insight into softmax classifiers and suggests future extensions to stochastic latent encoders and semi-supervised learning.
Abstract
We present a latent variable model for classification that provides a novel probabilistic interpretation of neural network softmax classifiers. We derive a variational objective to train the model, analogous to the evidence lower bound (ELBO) used to train variational auto-encoders, that generalises the softmax cross-entropy loss. Treating inputs to the softmax layer as samples of a latent variable, our abstracted perspective reveals a potential inconsistency between their anticipated distribution, required for accurate label predictions, and their empirical distribution found in practice. We augment the variational objective to mitigate such inconsistency and induce a chosen latent distribution, instead of the implicit assumption found in a standard softmax layer. Overall, we provide new theoretical insight into the inner workings of widely-used softmax classifiers. Empirical evaluation on image and text classification datasets demonstrates that our proposed approach, variational classification, maintains classification accuracy while the reshaped latent space improves other desirable properties of a classifier, such as calibration, adversarial robustness, robustness to distribution shift and sample efficiency useful in low data settings.
