Skip to content

Commit

Permalink
Merge pull request #115 from stefanradev93/Development
Browse files Browse the repository at this point in the history
Merge with dev
  • Loading branch information
stefanradev93 authored Dec 11, 2023
2 parents fda4479 + 3d1d792 commit ec61454
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 87 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# BayesFlow <img src="https://github.com/stefanradev93/BayesFlow/blob/master/img/bayesflow_hex.png?raw=true" align="right" width=20% height=20% />

[![Actions Status](https://github.com/stefanradev93/bayesflow/workflows/Tests/badge.svg)](https://github.com/stefanradev93/bayesflow/actions)
[![Licence](https://img.shields.io/github/license/stefanradev93/BayesFlow)](https://img.shields.io/github/license/stefanradev93/BayesFlow)
[![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.05702/status.svg)](https://doi.org/10.21105/joss.05702)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)


Welcome to our BayesFlow library for efficient simulation-based Bayesian workflows! Our library enables users to create specialized neural networks for *amortized Bayesian inference*, which repay users with rapid statistical inference after a potentially longer simulation-based training phase.

Expand Down
4 changes: 2 additions & 2 deletions bayesflow/computational_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def posterior_calibration_error(
The random draws from the approximate posteriors over ``num_datasets``
prior_samples : np.ndarray of shape (num_datasets, num_params)
The corresponding ground-truth values sampled from the prior
alpha_resolution : int, optional, default: 100
alpha_resolution : int, optional, default: 20
The number of credibility intervals (CIs) to consider
aggregator_fun : callable or None, optional, default: np.median
The function used to aggregate the marginal calibration errors.
Expand Down Expand Up @@ -233,7 +233,7 @@ def mmd_kernel_unbiased(x, y, kernel):
Returns
-------
loss : tf.Tensor of shape (,)
The statistically unbiaserd squared maximum mean discrepancy (MMD) value.
The statistically unbiased squared maximum mean discrepancy (MMD) value.
"""

m, n = x.shape[0], y.shape[0]
Expand Down
2 changes: 1 addition & 1 deletion bayesflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


class DefaultJointConfigurator:
"""Fallback class for a generic configrator for joint posterior and likelihood approximation."""
"""Fallback class for a generic configurator for joint posterior and likelihood approximation."""

def __init__(self, default_float_type=np.float32):
self.posterior_config = DefaultPosteriorConfigurator(default_float_type=default_float_type)
Expand Down
10 changes: 5 additions & 5 deletions bayesflow/coupling_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def _calculate_spline(self, target, spline_params, inverse=False):
target : tf.Tensor of shape (batch_size, ..., dim_2)
The target partition of the input vector to transform.
spline_params : tuple(tf.Tensor,...)
A tuple with tensors corresponding to the learnbale spline features:
A tuple with tensors corresponding to the learnable spline features:
(left_edge, bottom_edge, widths, heights, derivatives)
inverse : bool, optional, default: False
Flag indicating whether to run the block forward or backward.
Expand Down Expand Up @@ -516,7 +516,7 @@ def __init__(
for the required entries.
coupling_design : str or callable, optional, default: 'affine'
The type of internal coupling network to use. Must be in ['affine', 'spline'].
In general, spline couplings run slower than affine couplings, but require fewers coupling
In general, spline couplings run slower than affine couplings, but requires fewer coupling
layers. Spline couplings may work best with complex (e.g., multimodal) low-dimensional
problems. The difference will become less and less pronounced as we move to higher dimensions.
permutation : str or None, optional, default: 'fixed'
Expand Down Expand Up @@ -581,15 +581,15 @@ def __init__(
self.act_norm = None

def call(self, target_or_z, condition, inverse=False, **kwargs):
"""Performs one pass through a the affine coupling layer (either inverse or forward).
"""Performs one pass through the affine coupling layer (either inverse or forward).
Parameters
----------
target_or_z : tf.Tensor
The estimation quantites of interest or latent representations z ~ p(z), shape (batch_size, ...)
The estimation quantities of interest or latent representations z ~ p(z), shape (batch_size, ...)
condition : tf.Tensor or None
The conditioning data of interest, for instance, x = summary_fun(x), shape (batch_size, ...).
If `condition is None`, then the layer recuces to an unconditional ACL.
If `condition is None`, then the layer reduces to an unconditional ACL.
inverse : bool, optional, default: False
Flag indicating whether to run the block forward or backward.
Expand Down
5 changes: 5 additions & 0 deletions bayesflow/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,8 @@ def __init__(self, meta_dict: dict, mandatory_fields: list = []):


MMD_BANDWIDTH_LIST = [1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1, 5, 10, 15, 20, 25, 30, 35, 100, 1e3, 1e4, 1e5, 1e6]

# Minimum time interval between tqdm status updates to reduce
# load. Only respected when refresh=False in set_postfix
# and set_postfix_str
TQDM_MININTERVAL = 0.1 # in seconds
Loading

0 comments on commit ec61454

Please sign in to comment.