bayesflow


Namebayesflow JSON
Version 2.0.7 PyPI version JSON
download
home_pageNone
SummaryAmortizing Bayesian Inference With Neural Networks
upload_time2025-08-27 07:48:45
maintainerNone
docs_urlNone
authorThe BayesFlow Team
requires_python<3.13,>=3.10
licenseMIT License Copyright (c) 2024 The BayesFlow Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BayesFlow <img src="img/bayesflow_hex.png" style="float: right; width: 20%; height: 20%;" align="right" alt="BayesFlow Logo" />
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/bayesflow-org/bayesflow/tests.yaml?style=for-the-badge&label=Tests)
![Codecov](https://img.shields.io/codecov/c/github/bayesflow-org/bayesflow?style=for-the-badge&link=https%3A%2F%2Fapp.codecov.io%2Fgh%2Fbayesflow-org%2Fbayesflow%2Ftree%2Fmain)
[![DOI](https://img.shields.io/badge/DOI-10.21105%2Fjoss.05702-blue?style=for-the-badge)](https://doi.org/10.21105/joss.05702)
![PyPI - License](https://img.shields.io/pypi/l/bayesflow?style=for-the-badge)
![NumFOCUS Affiliated Project](https://img.shields.io/badge/NumFOCUS-Affiliated%20Project-orange?style=for-the-badge)

BayesFlow is a Python library for simulation-based **Amortized Bayesian Inference** with neural networks.
It provides users and researchers with:

- A user-friendly API for rapid Bayesian workflows
- A rich collection of neural network architectures
- Multi-backend support via [Keras3](https://keras.io/keras_3/): You can use [PyTorch](https://github.com/pytorch/pytorch), [TensorFlow](https://github.com/tensorflow/tensorflow), or [JAX](https://github.com/google/jax)

BayesFlow (version 2+) is designed to be a flexible and efficient tool that enables rapid statistical inference
fueled by continuous progress in generative AI and Bayesian inference.

> [!IMPORTANT]
> As the 2.0 version introduced many new features, we still have to make breaking changes from time to time.
> This especially concerns **saving and loading** of models. We aim to stabilize this from the 2.1 release onwards.
> Until then, consider pinning your BayesFlow 2.0 installation to an exact version, or re-training after an update
> for less costly models.

## Important Note for Existing Users

You are currently looking at BayesFlow 2.0+, which is a complete rewrite of the library.
While it shares the same overall goals with the 1.x versions, the API is not compatible.

> [!CAUTION]
> A few features, most notably hierarchical models, have not been ported to BayesFlow 2.0+
> yet. We are working on those features and plan to add them soon. You can find the complete
> list in the [FAQ](#faq) below.

The [Moving from BayesFlow v1.1 to v2.0](examples/From_BayesFlow_1.1_to_2.0.ipynb) guide
highlights how concepts and classes relate between the two versions.

## Conceptual Overview

<div align="center">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="./img/bayesflow_landing_dark.jpg">
  <source media="(prefers-color-scheme: light)" srcset="./img/bayesflow_landing_light.jpg">
  <img alt="Overview graphic on using BayesFlow. It is split in three columns: 1. Choose your backend: BayesFlow is based on Keras, so you can choose PyTorch, TensorFlow or JAX. 2. Define your simulator: You specify your simulator in Python, and use it to generate simulated data. 3. Choose your algorithm: You define a generative neural network that you can use for estimation after training." src="./img/bayesflow_landing_dark.jpg">
</picture>
</div>

A cornerstone idea of amortized Bayesian inference is to employ generative
neural networks for parameter estimation, model comparison, and model validation
when working with intractable simulators whose behavior as a whole is too
complex to be described analytically.

## Install

We currently support Python 3.10 to 3.12. You can install the latest stable version from PyPI using:

```bash
pip install "bayesflow>=2.0"
```

If you want the latest features, you can install from source:

```bash
pip install git+https://github.com/bayesflow-org/bayesflow.git@dev
```

If you encounter problems with this or require more control, please refer to the instructions to install from source below.

### Backend

To use BayesFlow, you will also need to install one of the following machine learning backends.
Note that BayesFlow **will not run** without a backend.

- [Install JAX](https://jax.readthedocs.io/en/latest/installation.html)
- [Install PyTorch](https://pytorch.org/get-started/locally/)
- [Install TensorFlow](https://www.tensorflow.org/install)

If you don't know which backend to use, we recommend JAX as it is currently the fastest backend.

As of version ``2.0.7``, the backend will be set automatically. If you have multiple backends, you can manually [set the backend environment variable as described by keras](https://keras.io/getting_started/#configuring-your-backend).
For example, inside your Python script write:

```python
import os
os.environ["KERAS_BACKEND"] = "jax"
import bayesflow
```

If you use conda, you can alternatively set this individually for each environment in your terminal. For example:

```bash
conda env config vars set KERAS_BACKEND=jax
```

Or just plainly set the environment variable in your shell:

```bash
export KERAS_BACKEND=jax
```

## Getting Started

Using the high-level interface is easy, as demonstrated by the minimal working example below:

```python
import bayesflow as bf

workflow = bf.BasicWorkflow(
    inference_network=bf.networks.CouplingFlow(),
    summary_network=bf.networks.TimeSeriesNetwork(),
    inference_variables=["parameters"],
    summary_variables=["observables"],
    simulator=bf.simulators.SIR()
)

history = workflow.fit_online(epochs=15, batch_size=32, num_batches_per_epoch=200)

diagnostics = workflow.plot_default_diagnostics(test_data=300)
```

For an in-depth exposition, check out our expanding list of resources below.

### Books

Many examples from [Bayesian Cognitive Modeling: A Practical Course](https://bayesmodels.com/) by Lee & Wagenmakers (2013) in [BayesFlow](https://kucharssim.github.io/bayesflow-cognitive-modeling-book/).

### Tutorial notebooks

1. [Linear regression starter example](examples/Linear_Regression_Starter.ipynb)
2. [From ABC to BayesFlow](examples/From_ABC_to_BayesFlow.ipynb)
3. [Two moons starter example](examples/Two_Moons_Starter.ipynb)
4. [Rapid iteration with point estimators](examples/Lotka_Volterra_Point_Estimation.ipynb)
5. [SIR model with custom summary network](examples/SIR_Posterior_Estimation.ipynb)
6. [Bayesian experimental design](examples/Bayesian_Experimental_Design.ipynb)
7. [Simple model comparison example](examples/One_Sample_TTest.ipynb)
8. [Likelihood estimation](examples/Likelihood_Estimation.ipynb)
9. [Multimodal data](examples/Multimodal_Data.ipynb)
10. [Moving from BayesFlow v1.1 to v2.0](examples/From_BayesFlow_1.1_to_2.0.ipynb)

More tutorials are always welcome! Please consider making a pull request if you have a cool application that you want to contribute.

## Contributing

If you want to contribute to BayesFlow, we recommend installing it from source, see [CONTRIBUTING.md](CONTRIBUTING.md) for more details.

## Reporting Issues

If you encounter any issues, please don't hesitate to open an issue here on [Github](https://github.com/bayesflow-org/bayesflow/issues) or ask questions on our [Discourse Forums](https://discuss.bayesflow.org/).

## Documentation \& Help

Documentation is available at https://bayesflow.org. Please use the [BayesFlow Forums](https://discuss.bayesflow.org/) for any BayesFlow-related questions and discussions, and [GitHub Issues](https://github.com/bayesflow-org/bayesflow/issues) for bug reports and feature requests.

## Citing BayesFlow

You can cite BayesFlow along the lines of:

- We approximated the posterior using neural posterior estimation (NPE) with learned summary statistics (Radev et al., 2020), as implemented in the BayesFlow framework for amortized Bayesian inference (Radev et al., 2023a).
- We approximated the likelihood using neural likelihood estimation (NLE) without hand-crafted summary statistics (Papamakarios et al., 2019), leveraging its implementation in BayesFlow for efficient and flexible inference.

1. Radev, S. T., Schmitt, M., Schumacher, L., Elsemüller, L., Pratz, V., Schälte, Y., Köthe, U., & Bürkner, P.-C. (2023a). BayesFlow: Amortized Bayesian workflows with neural networks. *The Journal of Open Source Software, 8(89)*, 5702.([arXiv](https://arxiv.org/abs/2306.16015))([JOSS](https://joss.theoj.org/papers/10.21105/joss.05702))
2. Radev, S. T., Mertens, U. K., Voss, A., Ardizzone, L., Köthe, U. (2020). BayesFlow: Learning complex stochastic models with invertible neural networks. *IEEE Transactions on Neural Networks and Learning Systems, 33(4)*, 1452-1466. ([arXiv](https://arxiv.org/abs/2003.06281))([IEEE TNNLS](https://ieeexplore.ieee.org/document/9298920))
3. Radev, S. T., Schmitt, M., Pratz, V., Picchini, U., Köthe, U., & Bürkner, P.-C. (2023b). JANA: Jointly amortized neural approximation of complex Bayesian models. *Proceedings of the Thirty-Ninth Conference on Uncertainty in Artificial Intelligence, 216*, 1695-1706. ([arXiv](https://arxiv.org/abs/2302.09125))([PMLR](https://proceedings.mlr.press/v216/radev23a.html))

**BibTeX:**

```
@article{bayesflow_2023_software,
  title = {{BayesFlow}: Amortized {B}ayesian workflows with neural networks},
  author = {Radev, Stefan T. and Schmitt, Marvin and Schumacher, Lukas and Elsemüller, Lasse and Pratz, Valentin and Schälte, Yannik and Köthe, Ullrich and Bürkner, Paul-Christian},
  journal = {Journal of Open Source Software},
  volume = {8},
  number = {89},
  pages = {5702},
  year = {2023}
}

@article{bayesflow_2020_original,
  title = {{BayesFlow}: Learning complex stochastic models with invertible neural networks},
  author = {Radev, Stefan T. and Mertens, Ulf K. and Voss, Andreas and Ardizzone, Lynton and K{\"o}the, Ullrich},
  journal = {IEEE transactions on neural networks and learning systems},
  volume = {33},
  number = {4},
  pages = {1452--1466},
  year = {2020}
}

@inproceedings{bayesflow_2023_jana,
  title = {{JANA}: Jointly amortized neural approximation of complex {B}ayesian models},
  author = {Radev, Stefan T. and Schmitt, Marvin and Pratz, Valentin and Picchini, Umberto and K\"othe, Ullrich and B\"urkner, Paul-Christian},
  booktitle = {Proceedings of the Thirty-Ninth Conference on Uncertainty in Artificial Intelligence},
  pages = {1695--1706},
  year = {2023},
  volume = {216},
  series = {Proceedings of Machine Learning Research},
  publisher = {PMLR}
}
```

## FAQ

-------------

**Question:**
I am starting with Bayesflow, which backend should I use?

**Answer:**
We recommend JAX as it is currently the fastest backend.

-------------

**Question:**
I am getting `ModuleNotFoundError: No module named 'tensorflow'` when I try to import BayesFlow.

**Answer:**
One of these applies:
- You want to use tensorflow as your backend, but you have not installed it.
See [here](https://www.tensorflow.org/install).


- You want to use a backend other than tensorflow, but have not set the environment variable correctly.
See [here](https://keras.io/getting_started/#configuring-your-backend).


- You have set the environment variable, but it is not being picked up by Python.
This can happen silently in some development environments (e.g., VSCode or PyCharm).
Try setting the backend as shown [here](https://keras.io/getting_started/#configuring-your-backend)
in your Python script via `os.environ`.

-------------

**Question:**
What is the difference between Bayesflow 2.0+ and previous versions?

**Answer:**
BayesFlow 2.0+ is a complete rewrite of the library. It shares the same
overall goals with previous versions, but has much better modularity
and extensibility. What is more, the new BayesFlow has multi-backend support via Keras3,
while the old version was based on TensorFlow.

-------------

**Question:**
Should I switch to BayesFlow 2.0+ now? Are there features that are still missing?

**Answer:**
In general, we recommend to switch, as the new version is easier to use and will continue
to receive improvements and new features. However, a few features are still missing, so you
might want to wait until everything you need has been ported to BayesFlow 2.0+.

Depending on your needs, you might not want to upgrade yet if one of the following applies:

- You have an ongoing project that uses BayesFlow 1.x, and you do not want to allocate
  time for migrating it to the new API.
- You have already trained models in BayesFlow 1.x, that you do not want to re-train
  with the new version. Loading models from version 1.x in version 2.0+ is not supported.
- You require a feature that was not ported to BayesFlow 2.0+ yet. To our knowledge,
  this applies to:
  * Two-level/Hierarchical models (planned for version 2.1): `TwoLevelGenerativeModel`, `TwoLevelPrior`.
  * Sensitivity analysis (partially discontinued): functionality from the `bayesflow.sensitivity` module. This is still
    possible, but we do no longer offer a special module for it. We plan to add a tutorial on this, see [#455](https://github.com/bayesflow-org/bayesflow/issues/455).
  * MCMC (discontinued): The `bayesflow.mcmc` module. We are considering other options
    to enable the use of BayesFlow in an MCMC setting.
  * Networks: `EvidentialNetwork`.
  * Model misspecification detection: MMD test in the summary space (see #384).

If you encounter any functionality that is missing and not listed here, please let us
know by opening an issue.

-------------

**Question:**
I still need the old BayesFlow for some of my projects. How can I install it?

**Answer:**
You can find and install the old Bayesflow version via the `stable-legacy` branch on GitHub.
The corresponding [documentation](https://bayesflow.org/stable-legacy/index.html) can be
accessed by selecting the "stable-legacy" entry in the version picker of the documentation.

You can also install the latest version of BayesFlow v1.x from PyPI using

```
pip install "bayesflow<2.0"
```

-------------

## Awesome Amortized Inference

If you are interested in a curated list of resources, including reviews, software, papers, and other resources related to amortized inference, feel free to explore our [community-driven list](https://github.com/bayesflow-org/awesome-amortized-inference). If you'd like a paper (by yourself or someone else) featured, please add it to the list with a pull request, an issue, or a message to the maintainers.

## Acknowledgments

This project is currently managed by researchers from Rensselaer Polytechnic Institute, TU Dortmund University, and Heidelberg University. It is partially funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) Projects 528702768 and 508399956. The project is further supported by Germany's Excellence Strategy -- EXC-2075 - 390740016 (Stuttgart Cluster of Excellence SimTech) and EXC-2181 - 390900948 (Heidelberg Cluster of Excellence STRUCTURES), the collaborative research cluster TRR 391 – 520388526, as well as the Informatics for Life initiative funded by the Klaus Tschira Foundation.

BayesFlow is a [NumFOCUS Affiliated Project](https://numfocus.org/sponsored-projects/affiliated-projects).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bayesflow",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "The BayesFlow Team",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d1/cf/971f0bd7dcf39abfccf8148fd50349e9b8d34058999848bd2f9e8b21d329/bayesflow-2.0.7.tar.gz",
    "platform": null,
    "description": "# BayesFlow <img src=\"img/bayesflow_hex.png\" style=\"float: right; width: 20%; height: 20%;\" align=\"right\" alt=\"BayesFlow Logo\" />\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/bayesflow-org/bayesflow/tests.yaml?style=for-the-badge&label=Tests)\n![Codecov](https://img.shields.io/codecov/c/github/bayesflow-org/bayesflow?style=for-the-badge&link=https%3A%2F%2Fapp.codecov.io%2Fgh%2Fbayesflow-org%2Fbayesflow%2Ftree%2Fmain)\n[![DOI](https://img.shields.io/badge/DOI-10.21105%2Fjoss.05702-blue?style=for-the-badge)](https://doi.org/10.21105/joss.05702)\n![PyPI - License](https://img.shields.io/pypi/l/bayesflow?style=for-the-badge)\n![NumFOCUS Affiliated Project](https://img.shields.io/badge/NumFOCUS-Affiliated%20Project-orange?style=for-the-badge)\n\nBayesFlow is a Python library for simulation-based **Amortized Bayesian Inference** with neural networks.\nIt provides users and researchers with:\n\n- A user-friendly API for rapid Bayesian workflows\n- A rich collection of neural network architectures\n- Multi-backend support via [Keras3](https://keras.io/keras_3/): You can use [PyTorch](https://github.com/pytorch/pytorch), [TensorFlow](https://github.com/tensorflow/tensorflow), or [JAX](https://github.com/google/jax)\n\nBayesFlow (version 2+) is designed to be a flexible and efficient tool that enables rapid statistical inference\nfueled by continuous progress in generative AI and Bayesian inference.\n\n> [!IMPORTANT]\n> As the 2.0 version introduced many new features, we still have to make breaking changes from time to time.\n> This especially concerns **saving and loading** of models. We aim to stabilize this from the 2.1 release onwards.\n> Until then, consider pinning your BayesFlow 2.0 installation to an exact version, or re-training after an update\n> for less costly models.\n\n## Important Note for Existing Users\n\nYou are currently looking at BayesFlow 2.0+, which is a complete rewrite of the library.\nWhile it shares the same overall goals with the 1.x versions, the API is not compatible.\n\n> [!CAUTION]\n> A few features, most notably hierarchical models, have not been ported to BayesFlow 2.0+\n> yet. We are working on those features and plan to add them soon. You can find the complete\n> list in the [FAQ](#faq) below.\n\nThe [Moving from BayesFlow v1.1 to v2.0](examples/From_BayesFlow_1.1_to_2.0.ipynb) guide\nhighlights how concepts and classes relate between the two versions.\n\n## Conceptual Overview\n\n<div align=\"center\">\n<picture>\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"./img/bayesflow_landing_dark.jpg\">\n  <source media=\"(prefers-color-scheme: light)\" srcset=\"./img/bayesflow_landing_light.jpg\">\n  <img alt=\"Overview graphic on using BayesFlow. It is split in three columns: 1. Choose your backend: BayesFlow is based on Keras, so you can choose PyTorch, TensorFlow or JAX. 2. Define your simulator: You specify your simulator in Python, and use it to generate simulated data. 3. Choose your algorithm: You define a generative neural network that you can use for estimation after training.\" src=\"./img/bayesflow_landing_dark.jpg\">\n</picture>\n</div>\n\nA cornerstone idea of amortized Bayesian inference is to employ generative\nneural networks for parameter estimation, model comparison, and model validation\nwhen working with intractable simulators whose behavior as a whole is too\ncomplex to be described analytically.\n\n## Install\n\nWe currently support Python 3.10 to 3.12. You can install the latest stable version from PyPI using:\n\n```bash\npip install \"bayesflow>=2.0\"\n```\n\nIf you want the latest features, you can install from source:\n\n```bash\npip install git+https://github.com/bayesflow-org/bayesflow.git@dev\n```\n\nIf you encounter problems with this or require more control, please refer to the instructions to install from source below.\n\n### Backend\n\nTo use BayesFlow, you will also need to install one of the following machine learning backends.\nNote that BayesFlow **will not run** without a backend.\n\n- [Install JAX](https://jax.readthedocs.io/en/latest/installation.html)\n- [Install PyTorch](https://pytorch.org/get-started/locally/)\n- [Install TensorFlow](https://www.tensorflow.org/install)\n\nIf you don't know which backend to use, we recommend JAX as it is currently the fastest backend.\n\nAs of version ``2.0.7``, the backend will be set automatically. If you have multiple backends, you can manually [set the backend environment variable as described by keras](https://keras.io/getting_started/#configuring-your-backend).\nFor example, inside your Python script write:\n\n```python\nimport os\nos.environ[\"KERAS_BACKEND\"] = \"jax\"\nimport bayesflow\n```\n\nIf you use conda, you can alternatively set this individually for each environment in your terminal. For example:\n\n```bash\nconda env config vars set KERAS_BACKEND=jax\n```\n\nOr just plainly set the environment variable in your shell:\n\n```bash\nexport KERAS_BACKEND=jax\n```\n\n## Getting Started\n\nUsing the high-level interface is easy, as demonstrated by the minimal working example below:\n\n```python\nimport bayesflow as bf\n\nworkflow = bf.BasicWorkflow(\n    inference_network=bf.networks.CouplingFlow(),\n    summary_network=bf.networks.TimeSeriesNetwork(),\n    inference_variables=[\"parameters\"],\n    summary_variables=[\"observables\"],\n    simulator=bf.simulators.SIR()\n)\n\nhistory = workflow.fit_online(epochs=15, batch_size=32, num_batches_per_epoch=200)\n\ndiagnostics = workflow.plot_default_diagnostics(test_data=300)\n```\n\nFor an in-depth exposition, check out our expanding list of resources below.\n\n### Books\n\nMany examples from [Bayesian Cognitive Modeling: A Practical Course](https://bayesmodels.com/) by Lee & Wagenmakers (2013) in [BayesFlow](https://kucharssim.github.io/bayesflow-cognitive-modeling-book/).\n\n### Tutorial notebooks\n\n1. [Linear regression starter example](examples/Linear_Regression_Starter.ipynb)\n2. [From ABC to BayesFlow](examples/From_ABC_to_BayesFlow.ipynb)\n3. [Two moons starter example](examples/Two_Moons_Starter.ipynb)\n4. [Rapid iteration with point estimators](examples/Lotka_Volterra_Point_Estimation.ipynb)\n5. [SIR model with custom summary network](examples/SIR_Posterior_Estimation.ipynb)\n6. [Bayesian experimental design](examples/Bayesian_Experimental_Design.ipynb)\n7. [Simple model comparison example](examples/One_Sample_TTest.ipynb)\n8. [Likelihood estimation](examples/Likelihood_Estimation.ipynb)\n9. [Multimodal data](examples/Multimodal_Data.ipynb)\n10. [Moving from BayesFlow v1.1 to v2.0](examples/From_BayesFlow_1.1_to_2.0.ipynb)\n\nMore tutorials are always welcome! Please consider making a pull request if you have a cool application that you want to contribute.\n\n## Contributing\n\nIf you want to contribute to BayesFlow, we recommend installing it from source, see [CONTRIBUTING.md](CONTRIBUTING.md) for more details.\n\n## Reporting Issues\n\nIf you encounter any issues, please don't hesitate to open an issue here on [Github](https://github.com/bayesflow-org/bayesflow/issues) or ask questions on our [Discourse Forums](https://discuss.bayesflow.org/).\n\n## Documentation \\& Help\n\nDocumentation is available at https://bayesflow.org. Please use the [BayesFlow Forums](https://discuss.bayesflow.org/) for any BayesFlow-related questions and discussions, and [GitHub Issues](https://github.com/bayesflow-org/bayesflow/issues) for bug reports and feature requests.\n\n## Citing BayesFlow\n\nYou can cite BayesFlow along the lines of:\n\n- We approximated the posterior using neural posterior estimation (NPE) with learned summary statistics (Radev et al., 2020), as implemented in the BayesFlow framework for amortized Bayesian inference (Radev et al., 2023a).\n- We approximated the likelihood using neural likelihood estimation (NLE) without hand-crafted summary statistics (Papamakarios et al., 2019), leveraging its implementation in BayesFlow for efficient and flexible inference.\n\n1. Radev, S. T., Schmitt, M., Schumacher, L., Elsem\u00fcller, L., Pratz, V., Sch\u00e4lte, Y., K\u00f6the, U., & B\u00fcrkner, P.-C. (2023a). BayesFlow: Amortized Bayesian workflows with neural networks. *The Journal of Open Source Software, 8(89)*, 5702.([arXiv](https://arxiv.org/abs/2306.16015))([JOSS](https://joss.theoj.org/papers/10.21105/joss.05702))\n2. Radev, S. T., Mertens, U. K., Voss, A., Ardizzone, L., K\u00f6the, U. (2020). BayesFlow: Learning complex stochastic models with invertible neural networks. *IEEE Transactions on Neural Networks and Learning Systems, 33(4)*, 1452-1466. ([arXiv](https://arxiv.org/abs/2003.06281))([IEEE TNNLS](https://ieeexplore.ieee.org/document/9298920))\n3. Radev, S. T., Schmitt, M., Pratz, V., Picchini, U., K\u00f6the, U., & B\u00fcrkner, P.-C. (2023b). JANA: Jointly amortized neural approximation of complex Bayesian models. *Proceedings of the Thirty-Ninth Conference on Uncertainty in Artificial Intelligence, 216*, 1695-1706. ([arXiv](https://arxiv.org/abs/2302.09125))([PMLR](https://proceedings.mlr.press/v216/radev23a.html))\n\n**BibTeX:**\n\n```\n@article{bayesflow_2023_software,\n  title = {{BayesFlow}: Amortized {B}ayesian workflows with neural networks},\n  author = {Radev, Stefan T. and Schmitt, Marvin and Schumacher, Lukas and Elsem\u00fcller, Lasse and Pratz, Valentin and Sch\u00e4lte, Yannik and K\u00f6the, Ullrich and B\u00fcrkner, Paul-Christian},\n  journal = {Journal of Open Source Software},\n  volume = {8},\n  number = {89},\n  pages = {5702},\n  year = {2023}\n}\n\n@article{bayesflow_2020_original,\n  title = {{BayesFlow}: Learning complex stochastic models with invertible neural networks},\n  author = {Radev, Stefan T. and Mertens, Ulf K. and Voss, Andreas and Ardizzone, Lynton and K{\\\"o}the, Ullrich},\n  journal = {IEEE transactions on neural networks and learning systems},\n  volume = {33},\n  number = {4},\n  pages = {1452--1466},\n  year = {2020}\n}\n\n@inproceedings{bayesflow_2023_jana,\n  title = {{JANA}: Jointly amortized neural approximation of complex {B}ayesian models},\n  author = {Radev, Stefan T. and Schmitt, Marvin and Pratz, Valentin and Picchini, Umberto and K\\\"othe, Ullrich and B\\\"urkner, Paul-Christian},\n  booktitle = {Proceedings of the Thirty-Ninth Conference on Uncertainty in Artificial Intelligence},\n  pages = {1695--1706},\n  year = {2023},\n  volume = {216},\n  series = {Proceedings of Machine Learning Research},\n  publisher = {PMLR}\n}\n```\n\n## FAQ\n\n-------------\n\n**Question:**\nI am starting with Bayesflow, which backend should I use?\n\n**Answer:**\nWe recommend JAX as it is currently the fastest backend.\n\n-------------\n\n**Question:**\nI am getting `ModuleNotFoundError: No module named 'tensorflow'` when I try to import BayesFlow.\n\n**Answer:**\nOne of these applies:\n- You want to use tensorflow as your backend, but you have not installed it.\nSee [here](https://www.tensorflow.org/install).\n\n\n- You want to use a backend other than tensorflow, but have not set the environment variable correctly.\nSee [here](https://keras.io/getting_started/#configuring-your-backend).\n\n\n- You have set the environment variable, but it is not being picked up by Python.\nThis can happen silently in some development environments (e.g., VSCode or PyCharm).\nTry setting the backend as shown [here](https://keras.io/getting_started/#configuring-your-backend)\nin your Python script via `os.environ`.\n\n-------------\n\n**Question:**\nWhat is the difference between Bayesflow 2.0+ and previous versions?\n\n**Answer:**\nBayesFlow 2.0+ is a complete rewrite of the library. It shares the same\noverall goals with previous versions, but has much better modularity\nand extensibility. What is more, the new BayesFlow has multi-backend support via Keras3,\nwhile the old version was based on TensorFlow.\n\n-------------\n\n**Question:**\nShould I switch to BayesFlow 2.0+ now? Are there features that are still missing?\n\n**Answer:**\nIn general, we recommend to switch, as the new version is easier to use and will continue\nto receive improvements and new features. However, a few features are still missing, so you\nmight want to wait until everything you need has been ported to BayesFlow 2.0+.\n\nDepending on your needs, you might not want to upgrade yet if one of the following applies:\n\n- You have an ongoing project that uses BayesFlow 1.x, and you do not want to allocate\n  time for migrating it to the new API.\n- You have already trained models in BayesFlow 1.x, that you do not want to re-train\n  with the new version. Loading models from version 1.x in version 2.0+ is not supported.\n- You require a feature that was not ported to BayesFlow 2.0+ yet. To our knowledge,\n  this applies to:\n  * Two-level/Hierarchical models (planned for version 2.1): `TwoLevelGenerativeModel`, `TwoLevelPrior`.\n  * Sensitivity analysis (partially discontinued): functionality from the `bayesflow.sensitivity` module. This is still\n    possible, but we do no longer offer a special module for it. We plan to add a tutorial on this, see [#455](https://github.com/bayesflow-org/bayesflow/issues/455).\n  * MCMC (discontinued): The `bayesflow.mcmc` module. We are considering other options\n    to enable the use of BayesFlow in an MCMC setting.\n  * Networks: `EvidentialNetwork`.\n  * Model misspecification detection: MMD test in the summary space (see #384).\n\nIf you encounter any functionality that is missing and not listed here, please let us\nknow by opening an issue.\n\n-------------\n\n**Question:**\nI still need the old BayesFlow for some of my projects. How can I install it?\n\n**Answer:**\nYou can find and install the old Bayesflow version via the `stable-legacy` branch on GitHub.\nThe corresponding [documentation](https://bayesflow.org/stable-legacy/index.html) can be\naccessed by selecting the \"stable-legacy\" entry in the version picker of the documentation.\n\nYou can also install the latest version of BayesFlow v1.x from PyPI using\n\n```\npip install \"bayesflow<2.0\"\n```\n\n-------------\n\n## Awesome Amortized Inference\n\nIf you are interested in a curated list of resources, including reviews, software, papers, and other resources related to amortized inference, feel free to explore our [community-driven list](https://github.com/bayesflow-org/awesome-amortized-inference). If you'd like a paper (by yourself or someone else) featured, please add it to the list with a pull request, an issue, or a message to the maintainers.\n\n## Acknowledgments\n\nThis project is currently managed by researchers from Rensselaer Polytechnic Institute, TU Dortmund University, and Heidelberg University. It is partially funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) Projects 528702768 and 508399956. The project is further supported by Germany's Excellence Strategy -- EXC-2075 - 390740016 (Stuttgart Cluster of Excellence SimTech) and EXC-2181 - 390900948 (Heidelberg Cluster of Excellence STRUCTURES), the collaborative research cluster TRR 391 \u2013 520388526, as well as the Informatics for Life initiative funded by the Klaus Tschira Foundation.\n\nBayesFlow is a [NumFOCUS Affiliated Project](https://numfocus.org/sponsored-projects/affiliated-projects).\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2024 The BayesFlow Developers\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "Amortizing Bayesian Inference With Neural Networks",
    "version": "2.0.7",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b2d8a0c8918a68ae135f0f01120d65fe00832ca0178e07db30a9d8a99157d3a1",
                "md5": "8b963d48ce8506419ebb6dc421e87e4b",
                "sha256": "8699b4e48a1224d2e9aee0a175fccdae62fee000358313e0a8b2cd896e7d4bde"
            },
            "downloads": -1,
            "filename": "bayesflow-2.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8b963d48ce8506419ebb6dc421e87e4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.10",
            "size": 422809,
            "upload_time": "2025-08-27T07:48:43",
            "upload_time_iso_8601": "2025-08-27T07:48:43.431287Z",
            "url": "https://files.pythonhosted.org/packages/b2/d8/a0c8918a68ae135f0f01120d65fe00832ca0178e07db30a9d8a99157d3a1/bayesflow-2.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d1cf971f0bd7dcf39abfccf8148fd50349e9b8d34058999848bd2f9e8b21d329",
                "md5": "2370f7e07c57363fbd99ffbd87c0296e",
                "sha256": "ea0a1062164e7f61019e7ab593e9909716eb19682de36595ea66e1c65d2dc247"
            },
            "downloads": -1,
            "filename": "bayesflow-2.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "2370f7e07c57363fbd99ffbd87c0296e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.10",
            "size": 270043,
            "upload_time": "2025-08-27T07:48:45",
            "upload_time_iso_8601": "2025-08-27T07:48:45.362506Z",
            "url": "https://files.pythonhosted.org/packages/d1/cf/971f0bd7dcf39abfccf8148fd50349e9b8d34058999848bd2f9e8b21d329/bayesflow-2.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-27 07:48:45",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "bayesflow"
}
        
Elapsed time: 2.63974s