LINFA

LINFA: a Python library for variational inference with normalizing flow and annealing - Published in JOSS (2024)

https://github.com/desreslab/linfa

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in JOSS metadata
  • Academic publication links
    Links to: sciencedirect.com
  • Committers with academic emails
    4 of 5 committers (80.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

annealing computational-expensive-models normalizing-flows variational-inference

Scientific Fields

Artificial Intelligence and Machine Learning Computer Science - 40% confidence
Last synced: 6 months ago · JSON representation

Repository

A Python library for variational inference with normalizing flow and annealing

Basic Info
  • Host: GitHub
  • Owner: desResLab
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 8.76 MB
Statistics
  • Stars: 16
  • Watchers: 1
  • Forks: 2
  • Open Issues: 0
  • Releases: 0
Topics
annealing computational-expensive-models normalizing-flows variational-inference
Created almost 3 years ago · Last pushed 11 months ago
Metadata Files
Readme Contributing License

README.md

License: MIT example workflow Documentation Status

LINFA

LINFA is a library for variational inference with normalizing flow and adaptive annealing. It is designed to accommodate computationally expensive models and difficult-to-sample posterior distributions with dependent parameters.

The code for the masked autoencoders for density estimation (MADE), masked autoregressive flow (MAF) and real non volume-preserving transformation (RealNVP) is based on the implementation provided by Kamen Bliznashki.

Installation

To install LINFA type

pip install linfa-vi

Documentation

The documentation can be found on readthedocs

References

Background theory and examples for LINFA are discussed in the two papers:

Requirements

  • PyTorch 1.13.1
  • Numpy 1.22
  • Matplotlib 3.6 (only plot functionalities linfa.plot_res)

Numerical Benchmarks

LINFA includes five numerical benchmarks:

  • Trivial example.
  • High dimensional example (Sobol' function).
  • Two-element Windkessel model (a.k.a. RC model).
  • Three-element Windkessel model (a.k.a. RCR model).
  • Friedman 1 dataset example.

The implementation of the lumped parameter network models (RC and RCR models) follows closely from the code developed by the Schiavazzi Lab at the University of Notre Dame.

To run the tests type sh python -m unittest linfa.linfa_test_suite.NAME_example To run a limited number of iterations (say 100), you can instead type sh it=100 python3 -m unittest linfa.linfa_test_suite.NAME_example where NAME need to be replaced by * trivial for the trivial example (Ex 1). * highdim for the high-dimensional example (Ex 2). * rc for the RC model (Ex 3). * rcr for the RCR model (Ex 4). * adaann for the Friedman model example (Ex 5). * rcr_nofas_adaann for the RCR model, combining NoFAS with adaptive annealing (AdaAnn)

If used with adaptive annealing (AdaAnn) the it=100 option runs 100 iterations only at T=1 (i.e., to approximate the untempered posterior distribution). Therefore the total number of iterations is generally higher than specified through the it option.

At regular intervals, set by the parameter experiment.save_interval, LINFA writes a few results files. The sub-string NAME refers to the experiment name specified in the experiment.name variable, and IT indicates the iteration at which the file is written. The results files are

  • log.txt contains the log profile information, i.e.
    • Iteration number.
    • Annealing temperature at each iteration.
    • Loss function at each iteration.
  • NAME_grid_IT contains the inputs where the true model was evaluated.
  • NAME_params_IT contains the batch of input parameters $\boldsymbol{z}_{K}$ in the physical space generated at iteration IT.
  • NAME_samples_IT contains the batch of normalized parameters (parameter values before the coordinate transformation) generated at iteration IT.
  • NAME_logdensity_IT contains the value of the log posterior density corresponding to each parameter realization.
  • NAME_outputs_IT contains the true model (or surrogate model) outputs for each batch sample at iteration IT.
  • NAME_IT.nf contains a backup of the normalizing flow parameters at iteration IT.

A post processing script is also available to plot all results. To run it type

sh python -m linfa.plot_res -n NAME -i IT -f FOLDER where NAME and IT are again the experiment name and iteration number corresponding to the result file of interest, while FOLDER is the name of the folder with the results of the inference task are kept. Also the file format can be specified throught the -p option (options: pdf, png, jpg) and images with dark background can be generated using the -d flag.

The coverage resulting from these tests can be found at this link

Usage

To use LINFA with your model you need to specify the following components:

  • A computational model.
  • A surrogate model.
  • A log-likelihood model.
  • An optional transformation.

In addition you need to specify a list of options as discussed in the documentation.

Tutorial

Two step-by-step tutorials (tutorial 1 and tutorial 2) are also available which will guide you through an inference problem for a ballistic simulation.

Contributing

If you are interested in contributing to this project, plase take a look at the contributed guide provided with LINFA.

Citation

Did you use LINFA? Please cite our paper using: @article{linfa-vi-paper, title={LINFA: a Python library for variational inference with normalizing flow and annealing}, author={Wang, Yu and Cobian, Emma R and Lee, Jubilee and Liu, Fang and Hauenstein, Jonathan D and Schiavazzi, Daniele E}, journal={arXiv preprint arXiv:2307.04675}, year={2023} }

Owner

  • Name: desResLab
  • Login: desResLab
  • Kind: organization

JOSS Publication

LINFA: a Python library for variational inference with normalizing flow and annealing
Published
April 05, 2024
Volume 9, Issue 96, Page 6309
Authors
Yu Wang
Department of Applied and Computational Mathematics and Statistics, University of Notre Dame, Notre Dame, IN 46556, USA.
Emma R. Cobian
Department of Applied and Computational Mathematics and Statistics, University of Notre Dame, Notre Dame, IN 46556, USA.
Jubilee Lee
Department of Applied and Computational Mathematics and Statistics, University of Notre Dame, Notre Dame, IN 46556, USA.
Fang Liu
Department of Applied and Computational Mathematics and Statistics, University of Notre Dame, Notre Dame, IN 46556, USA.
Jonathan D. Hauenstein
Department of Applied and Computational Mathematics and Statistics, University of Notre Dame, Notre Dame, IN 46556, USA.
Daniele E. Schiavazzi
Department of Applied and Computational Mathematics and Statistics, University of Notre Dame, Notre Dame, IN 46556, USA.
Editor
Oskar Laverny ORCID
Tags
variational inference normalizing flow adaptive posterior annealing physics-based models

GitHub Events

Total
  • Watch event: 1
  • Push event: 5
Last Year
  • Watch event: 1
  • Push event: 5

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 175
  • Total Committers: 5
  • Avg Commits per committer: 35.0
  • Development Distribution Score (DDS): 0.16
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
des d****i@n****u 147
cedric y****0@n****u 11
kylajones k****9@n****u 8
ercobian 5****n 6
Yu Wang w****1@s****u 3
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 15
  • Total pull requests: 0
  • Average time to close issues: 22 days
  • Average time to close pull requests: N/A
  • Total issue authors: 4
  • Total pull request authors: 0
  • Average comments per issue: 1.8
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • daneschi (5)
  • robmoss (4)
  • selimfirat (4)
  • lrnv (2)
Pull Request Authors
Top Labels
Issue Labels
enhancement (3) bug (2)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 115 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 54
  • Total maintainers: 1
pypi.org: linfa-vi

A Python library for inference with normalizing flow and annealing

  • Homepage: https://github.com/desResLab/LINFA
  • Documentation: https://linfa-vi.readthedocs.io/
  • License: Copyright © 2023 <copyright holders> 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.
  • Latest release: 1.6.6
    published almost 2 years ago
  • Versions: 54
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 115 Last month
Rankings
Dependent packages count: 7.2%
Average: 29.5%
Forks count: 30.3%
Stargazers count: 39.2%
Dependent repos count: 41.3%
Maintainers (1)
Last synced: 6 months ago