Skip to content

Commit 456b96d

Browse files
authored
Merge pull request #378 from bayesflow-org/update-docs
Update docs and list of maintainers.
2 parents d7da37f + 83b771f commit 456b96d

File tree

3 files changed

+143
-60
lines changed

3 files changed

+143
-60
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fueled by continuous progress in generative AI and Bayesian inference.
2020
<picture>
2121
<source media="(prefers-color-scheme: dark)" srcset="./img/bayesflow_landing_dark.jpg">
2222
<source media="(prefers-color-scheme: light)" srcset="./img/bayesflow_landing_light.jpg">
23-
<img alt="dsd" src="./img/bayesflow_landing_dark.jpg">
23+
<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">
2424
</picture>
2525
</div>
2626

docsrc/source/about.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
About us
22
========
33

4-
Core developers
5-
---------------
4+
Core maintainers
5+
----------------
66

7-
Active developers, in order of joining:
7+
* `Stefan Radev <https://github.com/stefanradev93>`__, Rensselaer Polytechnic Institute
8+
* `Lars Kühmichel <https://github.com/LarsKue>`__, TU Dortmund University
89

9-
* `Stefan Radev <https://github.com/stefanradev93>`__, Heidelberg University
10-
* `Ullrich Köthe <https://hci.iwr.uni-heidelberg.de/vislearn/people/ullrich-koethe/>`__, Heidelberg University
11-
* `Marvin Schmitt <https://www.marvinschmitt.com>`__, University of Stuttgart
12-
* `Paul Bürkner <https://paul-buerkner.github.io/>`__, TU Dortmund University
13-
* `Lukas Schumacher <https://www.psychologie.uni-heidelberg.de/person/lukas-schumacher>`__, Heidelberg University
14-
* `Lasse Elsemüller <https://www.psychologie.uni-heidelberg.de/person/lasse-elsemueller>`__, Heidelberg University
15-
* `Valentin Pratz <https://valentinpratz.de/>`__, Heidelberg University
16-
* `Yannik Schälte <https://yannikschaelte.github.io/>`__, University of Bonn
10+
Active maintainers
11+
------------------
12+
13+
A list of active maintainers can be found on
14+
`GitHub <https://github.com/bayesflow-org/bayesflow/graphs/contributors>`__.
1715

1816
Join the team
1917
-------------
2018

2119
If you are interested in contributing to BayesFlow, feel free to participate via GitHub.
22-
We welcome pull requests, bug reports, and feature requests. For other opportunities to work with us, contact `Stefan Radev <mailto:[email protected]?subject=BayesFlow>`__.
20+
We welcome pull requests, bug reports, and feature requests. For other opportunities to work with us,
21+
contact `Stefan Radev <mailto:[email protected]?subject=BayesFlow>`__.

docsrc/source/index.md

Lines changed: 131 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# BayesFlow
22

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

66
- A user-friendly API for rapid Bayesian workflows
77
- A rich collection of neural network architectures
8-
- 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)
8+
- 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)
99

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

1313
## Conceptual Overview
@@ -16,7 +16,7 @@ fueled by continuous progress in generative AI and Bayesian inference.
1616
<picture>
1717
<source media="(prefers-color-scheme: dark)" srcset="_static/bayesflow_landing_dark.jpg">
1818
<source media="(prefers-color-scheme: light)" srcset="_static/bayesflow_landing_light.jpg">
19-
<img alt="Overview graphic on using BayesFlow. It is split in three columns: 1. Choose you backend: BayesFlow is based on Keras, so you can choose PyTorch, TensorFlow or JAX. 2. Define your simulator: You specify you simulator in Python, and use it to generate simulated data. 3. Choose your algorithm: You define a generative nerual network, that you can use for estimation after training." src="_static/bayesflow_landing_dark.jpg">
19+
<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="_static/bayesflow_landing_dark.jpg">
2020
</picture>
2121
</div>
2222

@@ -25,78 +25,108 @@ neural networks for parameter estimation, model comparison, and model validation
2525
when working with intractable simulators whose behavior as a whole is too
2626
complex to be described analytically.
2727

28-
## Disclaimer
28+
## Getting Started
2929

30-
This is the current dev version of BayesFlow, which constitutes a complete refactor of the library built on Keras 3. This way, you can now use any of the major deep learning libraries as backend for BayesFlow. The refactor is still work in progress with some of the advanced features not yet implemented. We are actively working on them and promise to catch up soon.
30+
Using the high-level interface is easy, as demonstrated by the minimal working example below:
3131

32-
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/).
32+
```python
33+
import bayesflow as bf
3334

34-
## Installation
35+
workflow = bf.BasicWorkflow(
36+
inference_network=bf.networks.FlowMatching(),
37+
summary_network=bf.networks.TimeSeriesTransformer(),
38+
inference_variables=["parameters"],
39+
summary_variables=["observables"],
40+
simulator=bf.simulators.SIR()
41+
)
3542

36-
### Backend
43+
history = workflow.fit_online(epochs=50, batch_size=32, num_batches_per_epoch=500)
3744

38-
First, install one machine learning backend of choice. Note that BayesFlow **will not run** without a backend.
45+
diagnostics = workflow.plot_default_diagnostics(test_data=300)
46+
```
3947

40-
- [Install JAX](https://jax.readthedocs.io/en/latest/installation.html)
41-
- [Install PyTorch](https://pytorch.org/get-started/locally/)
42-
- [Install TensorFlow](https://www.tensorflow.org/install)
48+
For an in-depth exposition, check out our walkthrough notebooks below.
4349

44-
If you don't know which backend to use, we recommend JAX to get started.
45-
It is the fastest backend and already works pretty reliably with the current
46-
dev version of bayesflow.
50+
1. [Linear regression starter example](_examples/Linear_Regression_Starter.ipynb)
51+
2. [From ABC to BayesFlow](_examples/From_ABC_to_BayesFlow.ipynb)
52+
3. [Two moons starter example](_examples/Two_Moons_Starter.ipynb)
53+
4. [Rapid iteration with point estimators](_examples/Lotka_Volterra_point_estimation_and_expert_stats.ipynb)
54+
5. [SIR model with custom summary network](_examples/SIR_Posterior_Estimation.ipynb)
55+
6. [Bayesian experimental design](_examples/Bayesian_Experimental_Design.ipynb)
56+
7. [Simple model comparison example](_examples/One_Sample_TTest.ipynb)
4757

48-
Once installed, [set the backend environment variable as required by keras](https://keras.io/getting_started/#configuring-your-backend). For example, inside your Python script write:
58+
More tutorials are always welcome! Please consider making a pull request if you have a cool application that you want to contribute.
4959

50-
```python
51-
import os
52-
os.environ["KERAS_BACKEND"] = "jax"
53-
import bayesflow
54-
```
60+
## Install
61+
62+
```{eval-rst}
63+
.. tab-set::
5564
56-
If you use conda, you can alternatively set this individually for each environment in your terminal. For example:
65+
.. tab-item:: pip
5766
58-
```bash
59-
conda env config vars set KERAS_BACKEND=jax
67+
.. code-block:: bash
68+
69+
pip install bayesflow
70+
71+
.. tab-item:: source
72+
73+
.. code-block:: bash
74+
75+
pip install git+https://github.com/bayesflow-org/bayesflow.git
6076
```
6177

62-
This way, you also don't have to manually set the backend every time you are starting Python to use BayesFlow.
78+
### Backend
79+
80+
To use BayesFlow, you will also need to install one of the following machine learning backends.
81+
Note that BayesFlow **will not run** without a backend.
6382

64-
**Caution:** Some people report that the IDE (e.g., VSCode or PyCharm) can silently overwrite environment variables. If you have set your backend as an environment variable and you still get keras-related import errors when loading BayesFlow, these IDE shenanigans might be the culprit. Try setting the keras backend in your Python script via `import os; os.environ["KERAS_BACKEND"] = "<YOUR-BACKEND>"`.
83+
- [Install JAX](https://jax.readthedocs.io/en/latest/installation.html)
84+
- [Install PyTorch](https://pytorch.org/get-started/locally/)
85+
- [Install TensorFlow](https://www.tensorflow.org/install)
6586

66-
### BayesFlow
87+
If you don't know which backend to use, we recommend JAX as it is currently the fastest backend.
6788

68-
You can then install BayesFlow itself using one of the following options:
89+
Once installed, [set the backend environment variable as required by keras](https://keras.io/getting_started/#configuring-your-backend) to one of the following:
90+
91+
- `KERAS_BACKEND=jax`
92+
- `KERAS_BACKEND=torch`
93+
- `KERAS_BACKEND=tensorflow`
94+
95+
For example, to set the backend to `jax`, you can use one of the following:
6996

7097
```{eval-rst}
7198
.. tab-set::
7299
73-
.. tab-item:: Pip
100+
.. tab-item:: Python
74101
75-
.. code-block:: bash
102+
.. code-block:: python
76103
77-
pip install git+https://github.com/bayesflow-org/bayesflow@dev
104+
import os
105+
os.environ["KERAS_BACKEND"] = "jax"
106+
import bayesflow
78107
108+
.. tab-item:: Conda
79109
80-
.. tab-item:: Conda (coming soon)
110+
.. code-block:: bash
81111
82-
The dev version is not conda-installable yet.
112+
conda env config vars set KERAS_BACKEND=jax
83113
114+
.. tab-item:: Shell
84115
85-
.. tab-item:: Source
116+
.. code-block:: bash
86117
87-
.. code-block:: bash
118+
export KERAS_BACKEND=jax
119+
```
88120

89-
git clone -b dev [email protected]:bayesflow-org/bayesflow.git
90-
cd <local-path-to-bayesflow-repository>
91-
conda env create --file environment.yaml --name bayesflow
121+
**Caution:** Some development environments (e.g., VSCode or PyCharm) can silently overwrite environment variables. If you have set your backend as an environment variable and you still get keras-related import errors when loading BayesFlow, these IDE shenanigans might be the culprit. Try setting the keras backend in your Python script via `import os; os.environ["KERAS_BACKEND"] = "<YOUR-BACKEND>"`.
92122

93-
This will create a new conda environment. Please activate it and install your preferred backend.
94-
```
123+
## Contributing
95124

96-
## Getting Started
125+
To contribute to BayesFlow, please check out the [git repository](https://github.com/bayesflow-org/bayesflow)
126+
127+
### Reporting Issues
97128

98-
To get started, take a look at our [Getting Started Tutorial](_examples/Linear_Regression_Starter.ipynb).
99-
After that, check out some of our walk-through notebooks in the [Examples](examples) section.
129+
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/).
100130

101131
## Getting Help
102132

@@ -106,9 +136,8 @@ Please use the [BayesFlow Forums](https://discuss.bayesflow.org/) for any BayesF
106136

107137
You can cite BayesFlow along the lines of:
108138

109-
- We approximated the posterior with neural posterior estimation and learned summary statistics (NPE; Radev et al., 2020), as implemented in the BayesFlow software for amortized Bayesian workflows (Radev et al., 2023a).
110-
- We approximated the likelihood with neural likelihood estimation (NLE; Papamakarios et al., 2019) without hand-crafted summary statistics, as implemented in the BayesFlow software for amortized Bayesian workflows (Radev et al., 2023b).
111-
- We performed simultaneous posterior and likelihood estimation with jointly amortized neural approximation (JANA; Radev et al., 2023a), as implemented in the BayesFlow software for amortized Bayesian workflows (Radev et al., 2023b).
139+
- 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).
140+
- 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.
112141

113142
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))
114143
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))
@@ -149,6 +178,61 @@ You can cite BayesFlow along the lines of:
149178
}
150179
```
151180

181+
## FAQ
182+
183+
-------------
184+
185+
**Question:**
186+
I am starting with Bayesflow, which backend should I use?
187+
188+
**Answer:**
189+
We recommend JAX as it is currently the fastest backend.
190+
191+
-------------
192+
193+
**Question:**
194+
I am getting `ModuleNotFoundError: No module named 'tensorflow'` when I try to import BayesFlow.
195+
196+
**Answer:**
197+
One of these applies:
198+
- You want to use tensorflow as your backend, but you have not installed it.
199+
See [here](https://www.tensorflow.org/install).
200+
201+
202+
- You want to use a backend other than tensorflow, but have not set the environment variable correctly.
203+
See [here](https://keras.io/getting_started/#configuring-your-backend).
204+
205+
206+
- You have set the environment variable, but it is not being picked up by Python.
207+
This can happen silently in some development environments (e.g., VSCode or PyCharm).
208+
Try setting the backend as shown [here](https://keras.io/getting_started/#configuring-your-backend)
209+
in your Python script via `os.environ`.
210+
211+
-------------
212+
213+
**Question:**
214+
What is the difference between Bayesflow 2.0+ and previous versions?
215+
216+
**Answer:**
217+
BayesFlow 2.0+ is a complete rewrite of the library. It shares the same
218+
overall goals with previous versions, but has much better modularity
219+
and extensibility. What is more, the new BayesFlow has multi-backend support via Keras3,
220+
while the old version was based on TensorFlow.
221+
222+
-------------
223+
224+
**Question:**
225+
I still need the old BayesFlow for some of my projects. How can I install it?
226+
227+
**Answer:**
228+
You can find and install the old Bayesflow version via the `stable-legacy` branch on GitHub.
229+
230+
-------------
231+
232+
## Awesome Amortized Inference
233+
234+
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).
235+
152236
## Acknowledgments
153237

154238
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, Project 528702768). 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), as well as the Informatics for Life initiative funded by the Klaus Tschira Foundation.

0 commit comments

Comments
 (0)