A three-part introduction to amortized Bayesian inference with BayesFlow. Each part consists of a brief theoretical introduction, an exercise notebook and a matching solution notebook. All notebooks are designed to run on Google Colab.
Lecture slides: https://arrjon.github.io/BayesFlowTutorial/
The goal: by the end you understand how to do the Bayesian workflow with BayesFlow: how simulator → adapter → networks → workflow → diagnostics fits together, and how to push it further with diagnostics and diffusion-model guidance.
These exercises are built on and adapted from the BayesFlow tutorials and example notebooks. For the original tutorials, full documentation, and the example gallery, see the BayesFlow website: https://bayesflow.org.
| # | Topic | Level | You'll learn | Exercise | Solution |
|---|---|---|---|---|---|
| 1 | Linear Regression | 🟢 Beginner | Bridge from Pyro/NUTS to amortized inference: same model both ways, matching posteriors, and the payoff of amortization | Exercise | Solution |
| 2 | SIR + Diagnostics | 🟡 Intermediate | Time-series (GRU) summaries, diagnostics, and analysing parameter identifiability | Exercise | Solution |
| 3 | Diffusion + Guidance | 🔴 Advanced | Diffusion-model posteriors for a multimodal problem, and writing your own guidance constraint to steer sampling after training | Exercise | Solution |
Work through them in order — each assumes the concepts from the previous one.
Open a notebook via its "Open in Colab" badge (top of each notebook), then run the first
setup cell. That cell installs this project and all its dependencies (BayesFlow, JAX,
Pyro, scikit-learn, …) straight from GitHub via
pip install "git+https://github.com/arrjon/BayesFlowTutorial.git" — the dependency list
lives in pyproject.toml.
You may see a red pip dependency-conflict warning on Colab — google-colab pins
pandas==2.2.2, while BayesFlow 2.x requires pandas>=2.3.3. This one is unavoidable (and
harmless: the tutorial doesn't use google-colab's pandas features).
uv sync # installs everything from pyproject.toml
# or, without uv:
pip install "git+https://github.com/arrjon/BayesFlowTutorial.git"BayesFlow runs on JAX, PyTorch or TensorFlow; the notebooks default to JAX with GPU support.
- BayesFlow docs & example gallery: https://bayesflow.org
- SBC interpretation guide: https://hyunjimoon.github.io/SBC/articles/rank_visualizations.html
- Diffusion models in SBI (tutorial review): https://bayesflow-org.github.io/diffusion-experiments/