Abstract
The distribution of a neural network's latent representations has been successfully used to detect out-of-distribution (OOD) data. This work investigates whether this distribution moreover correlates with a model's epistemic uncertainty, thus indicates its ability to generalise to novel inputs. We first empirically verify that epistemic uncertainty can be identified with the surprise, thus the negative log-likelihood, of observing a particular latent representation. Moreover, we demonstrate that the output-conditional distribution of hidden representations also allows quantifying aleatoric uncertainty via the entropy of the predictive distribution. We analyse epistemic and aleatoric uncertainty inferred from the representations of different layers and conclude that deeper layers lead to uncertainty with similar behaviour as established - but computationally more expensive - methods (e.g. deep ensembles). While our approach does not require modifying the training process, we follow prior work and experiment with an additional regularising loss that increases the information in the latent representations. We find that this leads to improved OOD detection of epistemic uncertainty at the cost of ambiguous calibration close to the data distribution. We verify our findings on both classification and regression models.
Introduction
Deep neural networks are notoriously overconfident, often making "confidently wrong" predictions on data they have never encountered before. While Bayesian Deep Learning (BDL) provides a principled framework for uncertainty quantification, it is often computationally prohibitive and difficult to scale. This paper proposes an efficient alternative: extracting high-quality estimates of both epistemic (model-related) and aleatoric (data-related) uncertainty directly from a network's latent activations using density estimation.
Methodology
The core idea is to treat the activations of a trained network as a probability distribution. By applying density estimation tools—such as Gaussian Mixture Models (GMMs) for classification or Conditional Normalizing Flows (CNFs) for regression—we can quantify uncertainty post-hoc.
- Epistemic Uncertainty via "Surprise": Identified as the negative log-likelihood of a latent representation. High "surprise" indicates the model is processing an unfamiliar activation pattern.
- Aleatoric Uncertainty via Conditional Entropy: Estimated from the output-conditional distribution of hidden representations, measuring the inherent ambiguity in the predicted labels for a given activation.
The Role of Layer Depth
A significant finding is the trade-off between uncertainty estimates across different layers. Shallow layers provide "conservative" epistemic uncertainty, showing extreme sensitivity to low-level input perturbations. Deeper layers, conversely, capture high-level semantic features and behave similarly to more expensive ensemble methods.
Comparative Performance
The proposed density-based approach matches or even exceeds the performance of "gold standard" methods like Deep Ensembles and Monte Carlo (MC) Dropout in OOD detection tasks, while being significantly more computationally efficient.
Conclusion
This research demonstrates that latent representations in deterministic neural networks contain sufficient information to derive robust uncertainty measures. By leveraging density estimation, practitioners can add critical safety checks to existing AI systems without the need for multiple forward passes or extensive retraining. While challenges like "feature collapse" remain, the use of auxiliary losses offers a promising path toward scalable and reliable uncertainty quantification in deep learning.
Summary updated