Deep-UQ
Uncertainty quantification for deep learning. One package, 20+ methods, any PyTorch model.
What is Deep-UQ?¶
Deep-UQ is a PyTorch toolkit that adds calibrated uncertainty estimates to neural network predictions. Train your model normally, then wrap it with any of six UQ methods to get confidence intervals that grow when the model is unsure.
from deepuq.models import MLP
from deepuq.methods import LaplaceWrapper
model = MLP(input_dim=1, hidden_dims=[64, 64], output_dim=1)
# ... train as usual ...
la = LaplaceWrapper(model, likelihood="regression", hessian_structure="full")
la.fit(train_loader)
la.optimize_prior_precision()
result = la.predict_uq(x_test)
# result.mean, result.epistemic_var, result.total_var
6 Method Families
Deep Ensembles, Variational Inference, Laplace, SGLD, MC Dropout, and Gaussian Processes — all behind a unified predict_uq() API.
Scientific ML Ready
First-class support for FNO, DeepONet, Graph Neural Operators, PINNs, and convolutional surrogates with 36 executable tutorials.
Zero External UQ Dependencies
All methods implemented natively in PyTorch. No GPyTorch, no laplace-torch — just pip install uqdeepnn.
Choose Your Method¶
| If you need... | Use | Effort |
|---|---|---|
| Quick baseline, no retraining | MC Dropout or Test-Time Augmentation | Minimal |
| Post-hoc uncertainty on a trained model | Laplace or Temperature Scaling | Low |
| Single forward pass, distance-aware | SNGP or Evidential DL | Low |
| Single-run Bayesian approximation | SWAG / MultiSWAG | Low |
| Calibrated multi-model uncertainty | Deep Ensembles | Medium |
| Memory-efficient ensembles | Batch Ensemble or Packed Ensemble | Medium |
| Full Bayesian weight posteriors | Variational Inference or Flipout | Medium |
| Posterior samples via MCMC | SGLD / SGHMC / Cyclical SGMCMC | Medium |
| Particle-based inference | SVGD | Medium |
| Nonparametric with kernel priors | Gaussian Processes | Varies |
| Distribution-free coverage | Conformal Prediction (split, weighted, adaptive) | Low |
| Reject uncertain predictions | Selective Prediction | Low |
Laplace Backends (all native)¶
| Structure | Speed | Quality | Best for |
|---|---|---|---|
diag | Fastest | Good | Large models, quick estimates |
lowrank_diag | Fast | Better | Strong OOD detection |
block_diag | Medium | High | Good accuracy/speed balance |
kron | Medium | High | Multi-output layers |
full | Slow | Reference | Small models, maximum quality |
Model Architectures¶
| Family | Models | UQ Methods |
|---|---|---|
| Dense | MLP, PINN | All 6 methods |
| Spatial | CNN, ResNet, U-Net | Ensembles, MC Dropout, Laplace |
| Operators | DeepONet, FNO 2D/3D | Laplace, Ensembles |
| Graph | Graph Neural Operator | Ensembles, Laplace |
| GPs | Exact, Sparse, Deep Kernel, Multi-task | Native Bayesian |
Install¶
Or from source:
Beyond Prediction¶
| Module | What it does |
|---|---|
deepuq.metrics | ECE, CRPS, AUROC, PICP, Brier, AURC — evaluate UQ quality |
deepuq.active | Uncertainty-guided data acquisition (BALD, uncertainty sampling) |
deepuq.constraints | Physics constraints: positivity, conservation, monotonicity |
deepuq.propagation | Uncertainty growth tracking for autoregressive rollouts |
Tutorials¶
50+ executable notebooks covering every method and architecture:
- Core UQ methods — SWAG, SNGP, Evidential, Calibration, Selective Prediction
- Ensembles — Deep, Batch, Packed Ensembles
- MCMC — SGLD, SGHMC, Cyclical SGMCMC, SVGD
- Scientific ML — DeepONet, FNO, PINNs, CNNs, U-Nets, Graph Operators
- Gaussian Processes — Exact, Sparse, Multi-Fidelity, Deep Kernel
- Evaluation — Metrics, Active Learning, Uncertainty Propagation
Unified Output¶
Every method returns a UQResult with consistent fields:
result = method.predict_uq(x)
result.mean # predictive mean
result.epistemic_var # model uncertainty
result.aleatoric_var # data noise (when modeled)
result.total_var # combined uncertainty
Links¶
| Getting Started | Installation and quickstart |
| Method Guides | Mathematical details for each method |
| API Reference | Full class and function documentation |
| Tutorials | 36 executable notebook guides |
| Contributing | How to contribute |
| Changelog | Release history |