跑 examples/tutorials 里的模型需额外安装 pip install pyro-ppl[extras];extras 模型须与已安装的 Pyro 版本同源;README 未说明默认端口等其他限制

pyro
pyro-pplApache-2.0活跃维护基于 PyTorch 的深度概率编程库,用 Python 写贝叶斯模型,支持变分推断和 MCMC,适合做不确定性建模与生成模型研究。
Deep universal probabilistic programming with Python and PyTorch
基于 PyTorch 的通用深度概率编程库,用少量代码表达生成模型与推断
基于 PyTorch 的深度概率编程库,用 Python 写贝叶斯模型,支持变分推断和 MCMC,适合做不确定性建模与生成模型研究。
核心能力
- 可表示任意可计算的概率分布
- 以小型可组合抽象为核心实现
- 高层抽象写模型,专家可定制推断
- 相比手写代码开销小,可扩展大数据集
容易踩的坑
- 1.9.2最新正式版2026-10-03 · 2026-10-03 18:23 UTC
What's Changed
- Fix pyro parameter nodes not showing up in graph of pyro deterministic nodes [bugfix] by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3378
- Support for deterministic dependent samples in PyroSample [enhancement] by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3376
- Equalize effect handler by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3375
- Update mappings to Sphnix documentation of other projects [bugfix] by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3383
- Fix models not rendering after application of the equalize effect handler by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3387
- Support PyTorch 2.4 in tests by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3389
- Update CODE_OF_CONDUCT.md by @Swarnim114 in https://github.com/pyro-ppl/pyro/pull/3391
- add copyright and license headers to various files by @andife in https://github.com/pyro-ppl/pyro/pull/3384
- Make Predictive work with the SplitReparam reparameterizer [bugfix] by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3388
- Support for transformed distributions, based on stacking or concatenation transforms, in SplitReparam by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3390
- Support observations that require broadcasting in SplitReparam by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3392
- Type annotate
pyro.util.pyby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3393 - Fix torch documentation link by @fehiepsi in https://github.com/pyro-ppl/pyro/pull/3396
- Use more numerically stable
log1pin examples/scanvi/scanvi.py by @kit1980 in https://github.com/pyro-ppl/pyro/pull/3397 - Maintenance fixes by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3398
- Effect handler that conditions a model on sample sites having the same value by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3395
- Fix EqualizeMessenger type annotations by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3401
- Add batched calculation option to
energy_score_empiricalin order to reduce memory consumption by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3402 - Update example reference by @emmanuel-ferdman in https://github.com/pyro-ppl/pyro/pull/3403
- Fix
IndepMessenger.__iter__type annotation by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3406 - fix autodetermination of plate device when running in a device contexf by @ilia-kats in https://github.com/pyro-ppl/pyro/pull/3405
- attempt to add sphinx_copybutton by @mjste in https://github.com/pyro-ppl/pyro/pull/3408
- Fixed norm const for SBVM by @OlaRonning in https://github.com/pyro-ppl/pyro/pull/3411
- Doc note and assert that sbvm conc <= 10k by @OlaRonning in https://github.com/pyro-ppl/pyro/pull/3412
- Reconciling expert opinions example by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3413
- Add a centered variance option to the ClippedAdam optimizer by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3415
- Update intro_long.ipynb by @yannickeich in https://github.com/pyro-ppl/pyro/pull/3420
- Use the new github template by @fehiepsi in https://github.com/pyro-ppl/pyro/pull/3421
- don't log to the root logger by @ilia-kats in https://github.com/pyro-ppl/pyro/pull/3422
- fix datapath bart data by @juanitorduz in https://github.com/pyro-ppl/pyro/pull/3425
- Use datasets from GitHub instead of CloudFront. by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3427
- Update CI to latest Ubuntu image. by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3428
- Update CI Python version to 3.12. by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3429
- Support changing the function used to calculate the euclidean distance in energy_score_empirical. by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3431
- Fix docker build by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3432
- Fixes #3430 (serializing an easyguide corrupts it). by @BenZickel in https://g
- 1.9.12024-06-02 · 2024-06-02 00:37 UTC
查看更新说明
New Features
Stable.log_prob()is now implemented and differentiable by BenZickel in #3369, #3370- Introducing pyro.infer.predictive.WeighedPredictive which reports weights along with predicted samples by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3345
- Resampler for weighed samples by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3352
- Add function for calculating quantiles of weighed samples. by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3340
- Add effective sample size analytics to WeighedPredictive results by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3351
- Introducing PyroModuleList, because torch.nn.ModueList reinitializies modules when slice-indexing by @MartinBubel in https://github.com/pyro-ppl/pyro/pull/3339
Type hints
- Type annotate
pyro.nn.modulein https://github.com/pyro-ppl/pyro/pull/3337 - Fixes to type hints #3333, #3334
Additional changes
- small update doc HMC by @dario-coscia in https://github.com/pyro-ppl/pyro/pull/3335
- Type annotate
pyro.nn.dense_nnandpyro.nn.auto_reg_nnby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3342 - Enable type checking of the tests folder by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3336
- Auto regressive nn on gpu - revisited by @cafletezbrant in https://github.com/pyro-ppl/pyro/pull/3346
- GCC-8 CI error test by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3349
- Fix ruff version to 0.3.4 in order to overcome issue with version 0.3.5. by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3354
- Fix ruff settings & remove flake8 and isort settings by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3356
- Unpin ruff version by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3357
- Switch dependency from jupyter to notebook by @fritzo in https://github.com/pyro-ppl/pyro/pull/3360
- Add the energy score scoring rule for comparing multivariate distributions by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3362
- Add jupyter lab option to docker Makefile by @eteq in https://github.com/pyro-ppl/pyro/pull/3363
- Replace torch._utils._accumulate with numpy.cumsum. by @BenZickel in https://github.com/pyro-ppl/pyro/pull/3364
- Fix PyroModule rendering error in local-parameter mode by @eb8680 in https://github.com/pyro-ppl/pyro/pull/3366
New Contributors
- @dario-coscia made their first contribution in https://github.com/pyro-ppl/pyro/pull/3335
- @MartinBubel made their first contribution in https://github.com/pyro-ppl/pyro/pull/3339
- @BenZickel made their first contribution in https://github.com/pyro-ppl/pyro/pull/3340
- @cafletezbrant made their first contribution in https://github.com/pyro-ppl/pyro/pull/3346
- @eteq made their first contribution in https://github.com/pyro-ppl/pyro/pull/3363
Full Changelog: https://github.com/pyro-ppl/pyro/compare/1.9.0...1.9.1
- 1.9.02024-02-19 · 2024-02-19 18:02 UTC
查看更新说明
Breaking Changes
- Drop support for PyTorch 1
- Drop support for Python 3.7
New features
- Type hints are now available in some parts of Pyro, thanks to @ordabayevy. Please let us know about any issues. We welcome help adding type hints to remaining parts of Pyro. #2550
- New tutorials using Zuko normalizing flows by @francois-rozet
- A new simple RandomWalkKernel by @martinjankowiak
- A new SimplexToOrderedTransform by @peblair
- A new simple PyTorch training example by @eb8680
Detailed Changes
- Fix GammaPoisson distribution from ignoring validate_args param by @austinv11 in https://github.com/pyro-ppl/pyro/pull/3253
- Updated docs and fixed spelling by @martinrohbeck in https://github.com/pyro-ppl/pyro/pull/3254
- fix custom_guide in intro_long.ipynb by @martinjankowiak in https://github.com/pyro-ppl/pyro/pull/3258
- use generator arg in dataloader in cevae by @martinjankowiak in https://github.com/pyro-ppl/pyro/pull/3264
- SBVM sampler fix by @deoxyribose in https://github.com/pyro-ppl/pyro/pull/3261
- Render deterministic functions by @r3v1 in https://github.com/pyro-ppl/pyro/pull/3266
- Replace lap.lapjv() with scipy.optimize.linear_sum_assignment() by @fritzo in https://github.com/pyro-ppl/pyro/pull/3267
- Fix: Wrong codomain in LeakyReLUTransform by @MeenuyD in https://github.com/pyro-ppl/pyro/pull/3270
- Drop the support for PyTorch<2.0 by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3272
- Add
param_store.pytype hints by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3271 - Address the issues in #3274 by @cyianor in https://github.com/pyro-ppl/pyro/pull/3277
- Drop Python 3.7 support by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3278
- Update link to Nolan reference of Stable distribution by @fehiepsi in https://github.com/pyro-ppl/pyro/pull/3281
- Fix
pyro.poutine.handlersby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3283 - Add handlers explicitly by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3285
- Use
functools.wrapsto preservehandlersignature by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3287 - Type annotate
pyro.poutine.runtimeby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3288 - Type annotate
pyro.poutine.messengerby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3290 - Type annotate
pyro.primitives&poutine.block_messengerby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3292 - Add os to readthedocs.yml file by @fehiepsi in https://github.com/pyro-ppl/pyro/pull/3293
- Remove python.version entry in rtd.yml file by @fehiepsi in https://github.com/pyro-ppl/pyro/pull/3294
- Type annotate broadcast, condition, do, enum messengers by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3295
- Typo in the documentation example by @pavleb in https://github.com/pyro-ppl/pyro/pull/3298
- Type annotate
Trace,TraceMessenger, &pyro.poutine.guideby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3299 - Small typo in tutorial by @osorensen in https://github.com/pyro-ppl/pyro/pull/3300
- Update effect_handlers.ipynb by @djinnome in https://github.com/pyro-ppl/pyro/pull/3296
- Fix
gate&gate_logitsinZeroInflatedDistributionby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3303 - Type annotate poutines by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3306
- Numpy Import Convention by @RatishT in https://github.com/pyro-ppl/pyro/pull/3307
- Type annotate messengers by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3308
- Add simple RandomWalkKernel by @martinjankowiak in https://github.com/pyro-ppl/pyro/pull/3311
- Type annotate messengers by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3309
- Add tutorial
- 1.8.62023-07-29 · 2023-07-29 21:20 UTC
查看更新说明
Summary
- Reenable support for PyTorch 1.11 (after Pyro's 1.8.5 release had narrowly required torch>=2.0)
- Improve docstrings of Pyro's distribution wrappers around torch distributions #3246
What's Changed
- Refactor
ProvenanceTensorto usepytreeby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3223 - Create FUNDING.yml by @fritzo in https://github.com/pyro-ppl/pyro/pull/3224
- Remove DataParallel container in SS-VAE model by @martinrohbeck in https://github.com/pyro-ppl/pyro/pull/3227
- Fix jit ELBO sign error by @fritzo in https://github.com/pyro-ppl/pyro/pull/3229
- Replace flake8+isort with ruff by @fritzo in https://github.com/pyro-ppl/pyro/pull/3231
- fix _loc_scale method in AutoMultivariateNormal by @martinjankowiak in https://github.com/pyro-ppl/pyro/pull/3233
- Revert to support
torch>=1.11.0by @francois-rozet in https://github.com/pyro-ppl/pyro/pull/3242 - Concatenate torch docstrings at end of distribution wrappers by @fritzo in https://github.com/pyro-ppl/pyro/pull/3246
- Disable pdf builds on readthedocs by @fritzo in https://github.com/pyro-ppl/pyro/pull/3250
- Disable pdf and epub build on readthedocs by @fehiepsi in https://github.com/pyro-ppl/pyro/pull/3251
- Fix #3245 bug in poutine.trace(graph_type="dense") by @fritzo in https://github.com/pyro-ppl/pyro/pull/3247
- Bump version to to 1.8.6 by @fritzo in https://github.com/pyro-ppl/pyro/pull/3252
New Contributors
- @francois-rozet made their first contribution in https://github.com/pyro-ppl/pyro/pull/3242
- @rtviii collaborated with @fritzo in https://github.com/pyro-ppl/pyro/pull/3246
Full Changelog: https://github.com/pyro-ppl/pyro/compare/1.8.5...1.8.6
- 1.8.52023-05-29 · 2023-05-29 02:59 UTC
查看更新说明
This release includes a number of fixes to support PyTorch 2.
What's Changed
- Update base learning rate scheduler by @eb8680 in https://github.com/pyro-ppl/pyro/pull/3167
- Update GP tutorials to unblock #3174 by @fehiepsi in https://github.com/pyro-ppl/pyro/pull/3175
- add substitute handler by @thisiscam in https://github.com/pyro-ppl/pyro/pull/3125
- Update torch_patch.py by @S163669 in https://github.com/pyro-ppl/pyro/pull/3174
- fix: typo in log-absolute-derivative of exponential transform (normalizing flow tutorial) closes #3176 by @felixschltr in https://github.com/pyro-ppl/pyro/pull/3177
- rerun newest black on entire repo by @martinjankowiak in https://github.com/pyro-ppl/pyro/pull/3178
- Preserve path to the file when rendering model by @LysSanzMoreta in https://github.com/pyro-ppl/pyro/pull/3186
- Add conditional inverse and compose TransformModules by @eb8680 in https://github.com/pyro-ppl/pyro/pull/3185
- PyTorch Lightning example by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3189
- Fix & update GMM tutorial by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3193
- Fixing typos in
infer.inspectby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3198 - Bug fix about device of subsample in subsample_messenger.py by @hjnnjh in https://github.com/pyro-ppl/pyro/pull/3195
- Dependency tracking tutorial by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3197
- Make patch_dependency safer under dependency drift by @fritzo in https://github.com/pyro-ppl/pyro/pull/3204
- Deprecate
CorrLCholeskyTransformin favor of upstreamCorrCholeskyTransformby @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3199 - VAE: Improved ELBO plots by @martinrohbeck in https://github.com/pyro-ppl/pyro/pull/3205
- Remove vestigial lines from pyro/init.py all by @fritzo in https://github.com/pyro-ppl/pyro/pull/3210
- fix learning rate schedulers in PyTorch 2.0 (closes #3202) by @ilia-kats in https://github.com/pyro-ppl/pyro/pull/3207
- Clear .unconstrained weakrefs before pickling; rebuild them more often by @fritzo in https://github.com/pyro-ppl/pyro/pull/3212
- Add
pl.Trainerargs to argparse by @ordabayevy in https://github.com/pyro-ppl/pyro/pull/3217 - Run CI with PyTorch 2.0 by @eb8680 in https://github.com/pyro-ppl/pyro/pull/3192
- make ProvenanceTensor behave more like a Tensor (closes #3218) by @ilia-kats in https://github.com/pyro-ppl/pyro/pull/3220
- Bump version to 1.8.5 by @fritzo in https://github.com/pyro-ppl/pyro/pull/3222
New Contributors
- @thisiscam made their first contribution in https://github.com/pyro-ppl/pyro/pull/3125
- @S163669 made their first contribution in https://github.com/pyro-ppl/pyro/pull/3174
- @felixschltr made their first contribution in https://github.com/pyro-ppl/pyro/pull/3177
- @LysSanzMoreta made their first contribution in https://github.com/pyro-ppl/pyro/pull/3186
- @hjnnjh made their first contribution in https://github.com/pyro-ppl/pyro/pull/3195
- @martinrohbeck made their first contribution in https://github.com/pyro-ppl/pyro/pull/3205
- @ilia-kats made their first contribution in https://github.com/pyro-ppl/pyro/pull/3207
Full Changelog: https://github.com/pyro-ppl/pyro/compare/1.8.4...1.8.5
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Getting Started | Documentation | Community | Contributing
Pyro is a flexible, scalable deep probabilistic programming library built on PyTorch. Notably, it was designed with these principles in mind:
- Universal: Pyro is a universal PPL - it can represent any computable probability distribution.
- Scalable: Pyro scales to large data sets with little overhead compared to hand-written code.
- Minimal: Pyro is agile and maintainable. It is implemented with a small core of powerful, composable abstractions.
- Flexible: Pyro aims for automation when you want it, control when you need it. This is accomplished through high-level abstractions to express generative and inference models, while allowing experts easy-access to customize inference.
Pyro was originally developed at Uber AI and is now actively maintained by community contributors, including a dedicated team at the Broad Institute. In 2019, Pyro became a project of the Linux Foundation, a neutral space for collaboration on open source software, open standards, open data, and open hardware.
For more information about the high level motivation for Pyro, check out our launch blog post. For additional blog posts, check out work on experimental design and time-to-event modeling in Pyro.
Installing
Installing a stable Pyro release
Install using pip:
pip install pyro-ppl
Install from source:
git clone [email protected]:pyro-ppl/pyro.git
cd pyro
git checkout master # master is pinned to the latest release
pip install .
Install with extra packages:
To install the dependencies required to run the probabilistic models included in the examples/tutorials directories, please use the following command:
pip install pyro-ppl[extras]
Make sure that the models come from the same release version of the Pyro source code as you have installed.
Installing Pyro dev branch
For recent features you can install Pyro from source.
Install Pyro using pip:
pip install git+https://github.com/pyro-ppl/pyro.git
or, with the extras dependency to run the probabilistic models included in the examples/tutorials directories:
pip install git+https://github.com/pyro-ppl/pyro.git#egg=project[extras]
Install Pyro from source:
git clone https://github.com/pyro-ppl/pyro
cd pyro
pip install . # pip install .[extras] for running models in examples/tutorials
Running Pyro from a Docker Container
Refer to the instructions here.
Citation
If you use Pyro, please consider citing:
@article{bingham2019pyro,
author = {Eli Bingham and
Jonathan P. Chen and
Martin Jankowiak and
Fritz Obermeyer and
Neeraj Pradhan and
Theofanis Karaletsos and
Rohit Singh and
Paul A. Szerlip and
Paul Horsfall and
Noah D. Goodman},
title = {Pyro: Deep Universal Probabilistic Programming},
journal = {J. Mach. Learn. Res.},
volume = {20},
pages = {28:1--28:6},
year = {2019},
url = {http://jmlr.org/papers/v20/18-403.html}
}