Skip to content

Commit

Permalink
Merge branch 'dev' into pr/202
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed Nov 25, 2024
2 parents 15ad659 + c8837b7 commit bc0fcab
Show file tree
Hide file tree
Showing 163 changed files with 10,964 additions and 2,087 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ jobs:
- name: Run Linter
run: |
ruff check --config pyproject.toml
ruff check --config pyproject.toml --verbose
- name: Run Formatter
run: |
ruff format --check --config pyproject.toml
ruff format --check --config pyproject.toml --verbose
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11"]
Expand All @@ -69,7 +70,7 @@ jobs:
- name: Install JAX
if: ${{ matrix.backend == 'jax' }}
run: |
pip install -U "jax[cpu]"
pip install -U jax
- name: Install NumPy
if: ${{ matrix.backend == 'numpy' }}
run: |
Expand All @@ -90,6 +91,7 @@ jobs:
conda config --show-sources
conda config --show
printenv | sort
conda env export
- name: Run Tests
run: |
Expand Down
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement, contact person is
Stefan T. Radev (<[email protected]>).
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ pre-commit install
We recommend using the PyTorch backend for development.
Be careful not to downgrade your keras version when installing the backend.

You can also install a triple backend cuda environment using `cuda.yaml`:

```bash
conda env create --file cuda.yaml --name bf-cuda
```

Note that we cannot guarantee that this environment file will always work,
as it is not tested frequently or across devices.
It is provided merely as a convenience. For reliability, install only a single backend.

### 3. Implement your changes

In general, we recommend a test-driven development approach:
Expand Down
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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/stefanradev93/bayesflow/tests.yaml?style=for-the-badge&label=Tests)
![Codecov](https://img.shields.io/codecov/c/github/stefanradev93/bayesflow/streamlined-backend?style=for-the-badge)
![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/dev?style=for-the-badge)
[![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)

Expand All @@ -22,14 +22,14 @@ when working with intractable simulators whose behavior as a whole is too
complex to be described analytically. The figure below presents a higher-level
overview of neurally bootstrapped Bayesian inference.

<img src="https://github.com/stefanradev93/BayesFlow/blob/master/img/high_level_framework.png?raw=true" width=80% height=80%>
<img src="https://github.com/bayesflow-org/bayesflow/blob/master/img/high_level_framework.png?raw=true" width=80% height=80%>


## Disclaimer

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.

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

## Install

Expand All @@ -41,20 +41,22 @@ First, install one machine learning backend of choice. Note that BayesFlow **wil
- [Install PyTorch](https://pytorch.org/get-started/locally/)
- [Install TensorFlow](https://www.tensorflow.org/install)

If you are new to machine learning and don't know which one to use, we recommend PyTorch to get started.
If you don't know which backend to use, we recommend JAX to get started.
It is the fastest backend and already works pretty reliably with the current
dev version of bayesflow.

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:

```python
import os
os.environ["KERAS_BACKEND"] = "torch"
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=torch
conda env config vars set KERAS_BACKEND=jax
```

This way, you also don't have to manually set the backend every time you are starting Python to use BayesFlow.
Expand All @@ -66,7 +68,7 @@ This way, you also don't have to manually set the backend every time you are sta
You can install the dev version with pip:

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

### Using Conda (coming soon)
Expand All @@ -78,7 +80,7 @@ The dev version is not conda-installable yet.
If you want to contribute to BayesFlow, we recommend installing the dev branch from source:

```bash
git clone -b dev [email protected]:stefanradev93/bayesflow.git
git clone -b dev [email protected]:bayesflow-org/bayesflow.git
cd <local-path-to-bayesflow-repository>
conda env create --file environment.yaml --name bayesflow
```
Expand All @@ -87,11 +89,16 @@ conda env create --file environment.yaml --name bayesflow

Check out some of our walk-through notebooks below. We are actively working on porting all notebooks to the new interface so more will be available soon!

1. [Two moons toy example with flow matching](examples/TwoMoons_FlowMatching.ipynb)
1. [Two moons starter toy example](examples/TwoMoons_StarterNotebook.ipynb)
2. [Linear regression](examples/Linear_Regression.ipynb)
3. [Bayesian experimental design](examples/Bayesian_Experimental_Design.ipynb)
4. [SIR model with custom summary network](examples/SIR_PosteriorEstimation.ipynb)
5. [Hyperparameter optimization](examples/Hyperparameter_Optimization.ipynb)
6. Coming soon...

## 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/stefanradev93/BayesFlow/issues) for bug reports and feature requests.
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

Expand Down
5 changes: 3 additions & 2 deletions bayesflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from . import (
approximators,
benchmarks,
data_adapters,
adapters,
datasets,
diagnostics,
distributions,
Expand All @@ -11,8 +11,9 @@
)

from .approximators import ContinuousApproximator
from .adapters import Adapter
from .datasets import OfflineDataset, OnlineDataset, DiskDataset
from .benchmarks import TwoMoons
from .simulators import make_simulator


def setup():
Expand Down
2 changes: 2 additions & 0 deletions bayesflow/adapters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import transforms
from .adapter import Adapter
Loading

0 comments on commit bc0fcab

Please sign in to comment.