Package: linfa-vi
LINFALINFA 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 byKamen Bliznashki.InstallationTo install LINFA typepip install linfa-viDocumentationThe documentation can be found onreadthedocsReferencesBackground theory and examples for LINFA are discussed in the two papers:Y. Wang, F. Liu and D.E. Schiavazzi,Variational Inference with NoFAS: Normalizing Flow with Adaptive Surrogate for Computationally Expensive ModelsE.R. Cobian, J.D. Hauenstein, F. Liu and D.E. Schiavazzi,AdaAnn: Adaptive Annealing Scheduler for Probability Density ApproximationRequirementsPyTorch 1.13.1Numpy 1.22Matplotlib 3.6 (only plot functionalitieslinfa.plot_res)Numerical BenchmarksLINFA 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 bythe Schiavazzi Lab at the University of Notre Dame.To run the tests typepython-munittestlinfa.linfa_test_suite.NAME_examplewhereNAMEneed to be replaced bytrivialfor the trivial example (Ex 1).highdimfor the high-dimensional example (Ex 2).rcfor the RC model (Ex 3).rcrfor the RCR model (Ex 4).adaannfor the Friedman model example (Ex 5).rcr_nofas_adaannfor the RCR model, combining NoFAS with adaptive annealing (AdaAnn)At regular intervals set by the parameterexperiment.save_intervalLINFA writes a few results files. The sub-stringNAMErefers to the experiment name specified in theexperiment.namevariable, andITindicates the iteration at which the file is written. The results files arelog.txtcontains the log profile information, i.e.Iteration number.Annealing temperature at each iteration.Loss function at each iteration.NAME_grid_ITcontains the inputs where the true model was evaluated.NAME_params_ITcontains the batch of input parameters $\boldsymbol{z}_{K}$ in the physical space generated at iterationIT.NAME_samples_ITcontains the batch of normalized parameters (parameter values before the coordinate transformation) generated at iterationIT.NAME_logdensity_ITcontains the value of the log posterior density corresponding to each parameter realization.NAME_outputs_ITcontains the true model (or surrogate model) outputs for each batch sample at iterationIT.NAME_IT.nfcontains a backup of the normalizing flow parameters at iterationIT.A post processing script is also available to plot all results. To run it typepython-mlinfa.plot_res-nNAME-iIT-fFOLDERwhereNAMEandITare again the experiment name and iteration number corresponding to the result file of interest, whileFOLDERis the name of the folder with the results of the inference task are kept. Also the file format can be specified throught the-poption (options:pdf,png,jpg) and images with dark background can be generated using the-dflag.UsageTo 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 thedocumentation.TutorialTwo step-by-step tutorials (tutorial 1andtutorial 2) are also available which will guide you through the an inference problem for a ballistic simulation.CitationDid 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}
}