Abstract
Deep learning methods are increasingly becoming instrumental as modeling tools in computational neuroscience, employing optimality principles to build bridges between neural responses and perception or behavior. Developing models that adequately represent uncertainty is however challenging for deep learning methods, which often suffer from calibration problems. This constitutes a difficulty in particular when modeling cortical circuits in terms of Bayesian inference, beyond single point estimates such as the posterior mean or the maximum a posteriori. In this work we systematically studied uncertainty representations in latent representations of variational auto-encoders (VAEs), both in a perceptual task from natural images and in two other canonical tasks of computer vision, finding a poor alignment between uncertainty and informativeness or ambiguities in the images. We next showed how a novel approach which we call explaining-away variational auto-encoders (EA-VAEs), fixes these issues, producing meaningful reports of uncertainty in a variety of scenarios, including interpolation, image corruption, and even out-of-distribution detection. We show EA-VAEs may prove useful both as models of perception in computational neuroscience and as inference tools in computer vision.
Introduction
Variational Autoencoders (VAEs) are widely used in computational neuroscience and computer vision for their ability to learn compressed representations while providing a measure of uncertainty via posterior variance. However, standard VAEs often suffer from poor calibration, failing to increase uncertainty when faced with ambiguous or out-of-distribution (OOD) inputs. A primary reason for this is the "contrast paradox": in natural images, pixels are scaled together by global contrast, creating non-linear dependencies that standard VAEs—which assume independent or linearly correlated latents—cannot easily "explain away." Consequently, as image contrast decreases and the signal becomes less clear, VAE uncertainty often fails to rise appropriately, violating Bayesian logic.
Methods: The Explaining-Away VAE (EA-VAE)
To address these limitations, we introduce the Explaining-Away VAE (EA-VAE). The core innovation is the addition of a global scalar latent variable, $s$, to the generative model. While a standard VAE maps latents $z$ to an image $x$, the EA-VAE generative process is defined as $x = s \cdot f(z)$.
By providing a specific latent variable for global scaling, the inference network can "explain away" contrast variations. This allows the structural latent variables $z$ to focus purely on image features. Interestingly, the optimal inference mechanism for this model naturally implements "divisive normalization," a fundamental computation observed in biological visual systems where a neuron's response is normalized by the pooled activity of its neighbors. This allows the model to correctly revert to its prior state of uncertainty when input contrast is zero.
Results
The EA-VAE was evaluated against standard VAEs on natural image patches (Van Hateren) and benchmark datasets (MNIST, FashionMNIST, ChestMNIST) under various conditions.
Reliable Uncertainty under Corruption
As images are degraded by Gaussian blur or pixel noise, the EA-VAE's posterior standard deviation increases monotonically, reflecting the loss of information. As shown in Figure 4c, standard VAEs maintain a relatively flat and uninformative uncertainty profile despite the increasing signal degradation.
Out-of-Distribution (OOD) Detection
EA-VAEs demonstrate superior calibration for OOD detection. When presented with data from a different domain (e.g., X-rays for a model trained on digits), the EA-VAE reports uncertainty levels near the prior, effectively signaling its lack of knowledge. Standard VAEs often exhibit "unjustified certainty," assigning low uncertainty to inputs they have never seen (Figure 4d).
Ambiguity and Interpolation
During latent space interpolation (e.g., morphing a '2' into a '5'), the EA-VAE exhibits a clear peak in uncertainty at the midpoint where the image is most ambiguous. Standard VAEs fail to show a consistent pattern of uncertainty in these transitional states, often remaining overconfident in their hybrid representations (Figure 4b).
Conclusion
By explicitly modeling global scaling factors, the EA-VAE achieves principled uncertainty estimates that align with both Bayesian logic and biological visual processing motifs. This improved calibration makes EA-VAEs robust tools for both modeling perception in computational neuroscience and enhancing reliability in safety-critical computer vision applications.
Summary updated