Rethinking Approximate Gaussian Inference in Classification

Bálint Mucsányi, Nathaël Da Costa, Philipp Hennig

To capture epistemic uncertainty in classification, models often output Gaussian distributions over logits. However, pushing these through a standard softmax function requires costly Monte Carlo (MC) sampling. This paper proposes replacing the softmax activation with an element-wise normCDF or sigmoid function, enabling highly accurate, closed-form approximations of predictive probabilities. This simple swap entirely eliminates the runtime and memory overhead of MC sampling while matching or improving uncertainty quantification and out-of-distribution detection.

The Problem: The Bottleneck of Softmax Integration

Standard neural networks typically output point estimates that only capture aleatoric uncertainty (noise inherent in the data), missing the epistemic uncertainty (uncertainty in the model itself) crucial for safety-critical applications. To address this, researchers use approximate Gaussian inference methods like Laplace approximations or SNGP, which output a Gaussian distribution over the logit space.

However, obtaining final predictive probabilities requires integrating this Gaussian through the softmax function. This integral has no analytical solution, forcing practitioners to rely on Monte Carlo (MC) sampling. MC sampling is computationally expensive, scaling poorly at $O(S \cdot C + C^3)$ in runtime and $O(S \cdot C + C^2)$ in memory, where $S$ is the number of samples and $C$ is the number of classes. For modern tasks with thousands of classes, this overhead becomes a massive bottleneck.

Proposed Method: Bypassing Sampling with Analytical Swaps

The authors propose a framework to bypass MC sampling entirely by changing the network's output activation:

  • The Activation Swap: Instead of softmax, the model uses an element-wise standard Normal cumulative distribution function (normCDF) or a sigmoid function, followed by normalization.
  • Closed-Form Predictives: Because the integrals of Gaussians passed through normCDF (exact) and sigmoid (via probit approximation) are mathematically known, the authors derive closed-form formulas for predictive probabilities.
  • Dirichlet Moment Matching: The method approximates the entire pushforward distribution over the probability simplex using a Dirichlet distribution by matching the first two moments of the Gaussian pushforward.
  • Training Objective: Models are trained using a class-wise Binary Cross-Entropy (BCE) loss, which naturally fits the independent nature of the proposed activations.

Scalability and Theoretical Guarantees

A major concern with approximations is that they often degrade as the number of classes grows. However, the authors mathematically prove that the error of their closed-form approximation does not increase with the number of classes, making it highly scalable for modern vision tasks.

KL divergence between the approximate and true predictive distributions as the number of classes $C$ increases. The proposed closed-form methods (ours) maintain near-zero error compared to standard MC approaches.

As illustrated in Figure 1, the KL divergence to the true predictive distribution for the proposed methods remains negligible even as the number of classes reaches 200, whereas standard Softmax MC and other baselines show increasing error or significantly higher baseline divergence.

Key Results and Performance

The closed-form approach reduces the computational complexity of predictive approximation from $O(S \cdot C + C^3)$ to just $O(C)$. On a ResNet-50, this eliminates a ~7% inference time overhead caused by MC sampling, with even greater relative savings on smaller embedded models.

Performance comparison of closed-form approximations versus Monte Carlo sampling for Sigmoid and NormCDF Laplace backbones.

Empirical evaluations on ImageNet and CIFAR show that these closed-form predictives perform on par with or better than unbiased MC estimates (using 1000+ samples) across metrics like Expected Calibration Error (ECE) and Negative Log-Likelihood (NLL). Furthermore, the moment-matched Dirichlet distributions consistently achieved the highest AUROC for out-of-distribution (OOD) detection. For example, on ImageNet using a Sigmoid Laplace backbone, the Dirichlet analytical estimate scored an AUROC of 0.6388, beating the 1000-sample MC estimate of 0.6321.

Limitations and Future Outlook

While highly efficient, the current proposed predictives and Dirichlet distributions assume independence between classes, relying on the diagonal of the covariance matrix. They do not yet encode complex correlations between different class probabilities. Future research may explore more expressive, yet still mathematically tractable, second-order distributions on the simplex that can model these correlations, as well as deeper theoretical analysis of the intermediate Beta distribution approximations.

Summary updated

BibTeX
@inproceedings{mucsanyi2025rethinking,
  author = {Bálint Mucsányi and Nathaël Da Costa and Philipp Hennig},
  title = {{Rethinking Approximate Gaussian Inference in Classification}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=xPQyRmZ8hz},
}
Figure