Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BayesFlow Tutorial — Hands-on Exercises

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.

The three parts

# 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.

Running on Google Colab

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).

Running locally

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.

Further material

Contributors

Languages