Unified deep learning uncertainty quantification (UQ) toolkit: VI, Laplace, SGLD MCMC, MC Dropout (PyTorch)
Project description
deepuq
Unified deep learning uncertainty quantification (UQ) toolkit in PyTorch.
Implements four widely used methods:
- Variational Inference (VI) — Bayes by Backprop with BayesianLinear layers.
- Laplace Approximation — via
laplace-torchwith diagonal/kronecker/full Hessians. - MCMC (SGLD) — Stochastic Gradient Langevin Dynamics sampler for NN posteriors.
- MC Dropout — Keep dropout active at test-time and aggregate Monte Carlo predictions.
Install (local)
git clone https://github.com/yourusername/deepuq.git
cd deepuq
pip install -e .
Coming from PyPI? See the section Publish to PyPI below.
Quickstart
import torch
from deepuq.models.simple import MLP
from deepuq.methods.mc_dropout import MCDropoutWrapper
model = MLP(input_dim=784, hidden_dims=[256,128], output_dim=10, p_drop=0.2)
uq = MCDropoutWrapper(model, n_mc=50)
mean, var = uq.predict(torch.randn(32, 784))
print(mean.shape, var.shape)
See the examples/ folder for end‑to‑end training scripts on MNIST/FashionMNIST.
Methods
- VI: Place Gaussian posteriors over weights with reparameterization trick and KL regularization.
- Laplace: Fit a Gaussian around a MAP solution using the Hessian; calibrate with a prior precision.
- MCMC (SGLD): Inject Gaussian noise into SGD steps to sample from the posterior.
- MC Dropout: Use dropout at inference; Monte Carlo average for mean and variance.
Documentation
- API docs are in each module and the README sections below.
- Run
pydoc deepuq.methods.vietc., or open the examples.
Contributing
PRs welcome. Please add tests under tests/ and run pytest.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uqdeepnn-0.1.0.tar.gz.
File metadata
- Download URL: uqdeepnn-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
206f3e6266835af31ae5a584d404a8f3151782da9b9dcdff4843133fb2a90b67
|
|
| MD5 |
c3238028b73918ba6587e04113a1250c
|
|
| BLAKE2b-256 |
28ba208c8d36ef08ac7fe40ca75937b3d36a25afc925dab8bcd2a82a5de06257
|
File details
Details for the file uqdeepnn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: uqdeepnn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cad1a2dff9a0e20e96f4b573fa50037ec8d0b5c2a00846f9b13d56a959892eb5
|
|
| MD5 |
ffd2288f2098f96164a4cfb6da5f722f
|
|
| BLAKE2b-256 |
4cacc104752e6c681dfb8c3f59821e99f4d7dc1b865f7acd8d4a829dd9ad17f4
|