Skip to main content

Scalable Semi-Modular Inference with Variational Meta-Posteriors

License: MIT DOI:10.48550/arXiv.2204.00296 arXiv

This repo contain the implementation of variational methods described in the article Scalable Semi-Modular Inference with Variational Meta-Posteriors.

Abstract:

The Cut posterior and related Semi-Modular Inference (SMI) are Generalised Bayes methods for Modular Bayesian evidence combination. Analysis is broken up over modular sub-models of the joint posterior distribution. Model- misspecification in multi-modular models can be hard to fix by model elaboration alone and the Cut posterior and SMI offer a way round this. Information entering the analysis from misspecified modules is controlled by an influence parameter η related to the learning rate.

The article contains two substantial new methods. First, we give variational methods for approximating the Cut and SMI posteriors which are adapted to the inferential goals of evidence combination. We parameterise a family of variational posteriors using a Normalizing Flow for accurate approximation and end-to-end training. Secondly, we show that analysis of models with multiple cuts is feasible using a new Variational Meta-Posterior. This approximates a family of SMI posteriors indexed by η using a single set of variational parameters.

Examples

We provide code to replicate all the experiments from our article in the examples folder. There are main two examples: 1) epidemiological model and 2) random effects model. By executing the run.sh bash script in that folder, one can train all variational posteriors and produce visualizations and summaries (follow Installation instructions and examine run.sh before execution).

You can customize the output directories within the script and choose the experiments that you wish to run.

pip install -Ur examples/requirements.txt
chmod +x examples/run.sh
bash examples/run.sh

Results produced during the optimization can be monitored in Tensorboard:

tensorboard --logdir=$HOME/modularbayes-output

Installation instructions

  1. [Optional] Create a new virtual environment for this project (see Create a virtual environment below).
  2. Install JAX. This may vary according to your CUDA version (See JAX installation).
  3. Install the latest released version of modularbayes from Pypi via:
pip install -U modularbayes

or you can install the latest development version from GitHub:

pip install git+https://github.com/chriscarmona/modularbayes

Citation

If you find this work relevant for your scientific publication, we encourage you to add the following reference:

@misc{Carmona2022scalable,
    title = {Scalable Semi-Modular Inference with Variational Meta-Posteriors},
    year = {2022},
    author = {Carmona, Chris U. and Nicholls, Geoff K.},
    month = {4},
    url = {http://arxiv.org/abs/2204.00296},
    doi = {10.48550/arXiv.2204.00296},
    arxivId = {2204.00296},
    keywords = {Cut models, Generalized Bayes, Model misspecification, Scalable inference, Variational Bayes}
}

@InProceedings{Carmona2020smi,
  title = {Semi-Modular Inference: enhanced learning in multi-modular models by tempering the influence of components},
  author = {Carmona, Chris U. and Nicholls, Geoff K.},
  booktitle = {Proceedings of the 23rd International Conference on Artificial Intelligence and Statistics, AISTATS 2020},
  year = {2020},
  editor = {Silvia Chiappa and Roberto Calandra},
  volume = {108},
  pages = {4226--4235},
  series = {Proceedings of Machine Learning Research},
  month = {26--28 Aug},
  publisher = {PMLR},
  pdf = {http://proceedings.mlr.press/v108/carmona20a/carmona20a.pdf},
  url = {http://proceedings.mlr.press/v108/carmona20a.html},
  arxivId = {2003.06804},
}

Creating a virtual environment

For OSX or Linux, you can use venv (see the venv documentation).

rm -rf ~/.virtualenvs/modularbayes
python3 -m venv ~/.virtualenvs/modularbayes
source ~/.virtualenvs/modularbayes/bin/activate
pip install -U pip
pip install -U setuptools wheel

Feel free to change the folder where the virtual environment is created by replacing ~/.virtualenvs/modularbayes with a path of your choice in both commands.

Release files for modularbayes 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modularbayes 0.1.4
File Size Uploaded
modularbayes-0.1.4.tar.gz 52.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modularbayes 0.1.4
File Interpreter ABI Platform
modularbayes-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 138.0 kB

Release files / modularbayes-0.1.4.tar.gz

Download URL modularbayes-0.1.4.tar.gz
Size 52.5 kB
Tags Source
SHA-256 checksum
How to use checksums
227219297562ab8ed6bf0f654f4426760f6ce28a7f42f5a77dab236f8260a92d
BLAKE2b-256 checksum
How to use checksums
6971b26d86c0c7a9822f8cab845c1c30f51e3e9b57e4080af62fbcb9385613b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / modularbayes-0.1.4-py3-none-any.whl

Download URL modularbayes-0.1.4-py3-none-any.whl
Size 85.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac1b28eaa79900ba080b45634c5c9083323daec0a34465f60851f8187b9a9dcb
BLAKE2b-256 checksum
How to use checksums
09844294ba0700062433f414a789c4b401845a5cc048b89b3fbb494585abeb7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page