Bayesian Neural Networks & Uncertainty Quantification
Weight distributions, aleatoric vs epistemic uncertainty, dropout VI, last-layer Laplace, deep ensembles, conformal prediction
Standard neural networks output a prediction with no honest signal about confidence. A network that outputs 95% probability on every prediction — whether it has seen thousands of similar examples or none at all — is not expressing uncertainty, it is suppressing it. Bayesian Neural Networks address this by placing distributions over weights rather than point estimates, splitting predictive uncertainty into two types: irreducible noise in the data (aleatoric) and uncertainty from insufficient data coverage (epistemic).
In practice, full BNNs are infeasible at any useful scale. The empirical punchline is that deep ensembles — train several models from different random seeds — consistently beat most principled Bayesian approximations on calibration benchmarks. The reason is not Bayesian coverage; ensembles explore different loss basins and get function-space diversity that MC Dropout and most VI methods miss. Conformal prediction takes a completely different route: rigorous coverage guarantees with no Bayesian machinery at all.
Key points
- Aleatoric uncertainty is irreducible noise in the data itself. Infinite training data will not remove it. A blurry medical image has inherent label ambiguity regardless of training set size — the image does not contain enough information to determine the label with certainty. Model it explicitly: predict σ_θ(x) alongside μ_θ(x) so p(y|x,θ) = N(μ_θ(x), σ_θ(x)²). The network outputs the prediction and the noise level. Regions with consistently high σ_θ(x) after training signal inherent data ambiguity.
- Epistemic uncertainty comes from not having enough data in a region — it is reducible by collecting more data of that type. A well-calibrated model should be uncertain on out-of-distribution inputs and confident on in-distribution inputs. In a BNN, epistemic uncertainty = variance of E[y|x,θ] over the posterior p(θ|data). The operational use: high epistemic uncertainty in a specific region tells you exactly what data to collect next to reduce model uncertainty there.
- MC Dropout leaves dropout active at test time, runs T forward passes with different random dropout masks, and uses their variance as uncertainty. Zero architecture changes are required — this is why it is the most widely deployed BNN approximation. Formally it is equivalent to approximate VI in a specific deep GP model, but the formal correspondence requires dropout rates that practitioners rarely use. It works well enough as a heuristic despite the theoretical mismatch.
- Last-layer Laplace approximation: train to MAP, then fit a Gaussian posterior only on the last-layer weights W_last ~ N(W̃, H_last⁻¹). The Hessian is only d_last × d_last — feasible even for large networks where the full Hessian is prohibitive. Everything else stays as a point estimate. Strong practical baseline: reuses pretrained weights, no training changes, adds only a post-hoc Hessian computation. Calibrates well for classification. Fails for models where the feature extractor (not the last layer) is the source of uncertainty.
- Deep ensembles: train M independent networks from different random seeds. Predictive distribution = mixture of their M softmax outputs. Uncertainty = disagreement among ensemble members. Empirically dominates MC Dropout, last-layer Laplace, and most VI methods on calibration benchmarks. The cost is honest: M × training time and M × inference cost. There is no free lunch — ensembles are better because they are more expensive.
- Why ensembles outperform most Bayesian approximations: deep network loss landscapes are highly multimodal. Different random seeds converge to different loss basins, each corresponding to a functionally different solution. MC Dropout and VI both approximate a distribution localised around one basin. Ensembles explicitly sample different basins and get genuine function-space diversity. Their empirical advantage is loss-basin diversity, not Bayesian posterior coverage.
- Temperature scaling: after training, find scalar T on a held-out validation set by minimising NLL with scaled logits σ(f(x)/T). T > 1 softens predictions, T < 1 sharpens them. Accuracy is unchanged — argmax is invariant to positive scaling. One parameter, zero retraining, dramatically reduces ECE for the systematic overconfidence that cross-entropy training induces. This is mandatory before deploying any neural network classifier for probabilistic use.
- Conformal prediction provides a formal coverage guarantee with no distributional assumptions on the model. Compute nonconformity scores on a calibration set. Prediction set for a new x*: C(x*) = {y : score(x*,y) ≤ quantile_{1-α}(calibration scores)}. Guarantee: P(y* ∈ C(x*)) ≥ 1-α under exchangeability. The prediction set widens when the model is uncertain and shrinks when confident. It is the only uncertainty method with a formal coverage guarantee — all other methods are heuristic.
- OOD detection separates good uncertainty methods from bad ones. Neural networks are notoriously overconfident on OOD inputs — high softmax probability for inputs that look nothing like the training distribution. Deep ensembles produce better OOD uncertainty than single-model methods because disagreement among ensemble members is high for novel inputs. Conformal prediction is the only method with a formal guarantee: if the test input comes from the same distribution as the calibration set, coverage is guaranteed.
Deep ensembles consistently outperform MC Dropout and most VI-based BNN approximations on calibration benchmarks, and their advantage is function-space diversity from different loss basins — not Bayesian posterior coverage. The aleatoric/epistemic distinction has a concrete operational meaning: aleatoric uncertainty cannot be reduced by collecting more data, while epistemic uncertainty is a direct signal of where more data will improve the model. Conformal prediction is the only method with a formal marginal coverage guarantee under exchangeability — everything else is heuristic.
Recap
- BNNs put distributions over weights to split uncertainty into aleatoric (irreducible noise) vs epistemic (data coverage).
- Aleatoric = irreducible (more data won't help); epistemic = reducible — high epistemic tells you exactly where to collect data.
- MC Dropout: dropout on at test time, T passes, variance = uncertainty — zero architecture change, most-deployed heuristic.
- Last-layer Laplace: Gaussian posterior on final weights only ($d_{last} × d_{last}$ Hessian) — strong post-hoc baseline.
- Deep ensembles beat MC Dropout / VI on calibration — advantage is function-space diversity across loss basins, not Bayesian coverage.
- Temperature scaling (scalar T on logits) — accuracy unchanged, cuts overconfidence; mandatory before probabilistic deployment.
- Conformal prediction: only method with a formal coverage guarantee $P(y^* ∈ C(x^*)) ≥ 1-α$ under exchangeability.
Check your understanding
Q1. A model predicts 90% probability that a tumour is benign. Select the two correct statements about distinguishing aleatoric from epistemic uncertainty here.
- A) Aleatoric uncertainty persists even with more training data of the same kind, since it reflects irreducible noise in the imaging.
- B) Epistemic uncertainty shrinks as more relevant training data is collected, since it reflects a gap in data coverage rather than noise.
- C) Both types are always eliminated identically by applying temperature scaling to the model's output before deployment.
- D) Epistemic uncertainty is intrinsic to the imaging sensor and cannot be reduced by collecting any additional data.
Q2. You need uncertainty estimates for a 100M-parameter production model. MC Dropout adds 100ms per call (20 forward passes). What alternatives exist?
- A) Increase dropout rate to 0.9 — higher dropout reduces the passes needed from 20 down to 2, cutting latency while preserving uncertainty quality.
- B) There are no practical alternatives whatsoever; MC Dropout remains the only method that functions for models above 10M parameters at any scale.
- C) Last-layer Laplace, single-pass deterministic methods (SNGP, DUQ), conformal prediction, or ensemble distillation — each with lower overhead.
- D) Switch to a smaller 10M-parameter model entirely, since uncertainty quality scales proportionally with model size in production systems.
Q3. What guarantee does conformal prediction provide, and what assumption can violate it?
- A) Conformal prediction guarantees the prediction set always contains exactly one correct label, assuming the model achieves above 80% calibration accuracy.
- B) Guarantees P(y*∈C(x*)) ≥ 1-α under exchangeability. Fails under distribution shift, temporal non-stationarity, or selective prediction.
- C) Conformal prediction guarantees conditional coverage for every specific input individually; the assumption violated is perfect model calibration.
- D) Conformal prediction guarantees the prediction set has minimal possible size; the assumption violated is that the model must be a neural network.
Try it interactively
ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.
Open ML Systems Lab →