Pyro is a flexible, scalable deep probabilistic programming library built on PyTorch. It enables expressive deep probabilistic modeling, unifying modern deep learning and Bayesian inference. Maintained by community contributors, including a team at the Broad Institute, Pyro is under active development with frequent releases.
pip install torch
pip install pyro-pplVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a simple Bayesian coin-tossing model using Stochastic Variational Inference (SVI). It defines a probabilistic `model`, a variational `guide`, uses synthetic data, performs inference, and extracts the learned posterior parameters for the coin's bias.
Upgrade your PyTorch installation to version 2.x or later, and ensure your Python environment is 3.8 or newer. E.g., `pip install 'torch>=2.0.0' && pip install pyro-ppl`.
Upgrade your Python environment to version 3.7 or newer. Python 3.8+ is recommended for recent Pyro versions.
Refer to the official Pyro documentation or GitHub release notes for the exact PyTorch version compatibility when encountering issues or upgrading Pyro. It is generally safe to use the latest stable PyTorch 2.x with current Pyro versions.
Replace `for i in range(N): pyro.sample(f'x_{i}', ...)` with `with pyro.plate('name', N): pyro.sample('x', ...)`.Always specify a sufficient number of `warmup_steps` when initializing `pyro.infer.MCMC` (e.g., `mcmc = MCMC(kernel, num_samples=1000, warmup_steps=1000)`). Monitor convergence metrics like R-hat to assess if the warmup was adequate.