Skip to content

This repository is the official implementation of Quantized Variational Inference (NeurIPS 2020).

License

Notifications You must be signed in to change notification settings

amirdib/quantized-variational-inference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python version

This repository is the official implementation of Quantized Variational Inference (NeurIPS 2020).

Install

Install python requirements in your virtual environnement:

pip install -U setuptools #important to have the last version
pip install -r requirements.txt
pip install -e .

To use the jupyter notebook, it is necessary to install the kernel as follow

# For instance, with conda.
conda create -n virtual_env
source activate virtual_env    # On Windows, remove the word 'source'

python -m ipykernel install --user --name virtual_env_name

Download the complete OQ grids with the following command

cd data
bash ingest.sh

Usage

Using Tensorflow Probability Variational Inference Interface, given a taget_log_prob function and a surrogate_posterior func (the variational family), a Tensorflow Optimizer

from qvi.core.vi import QuantizedVariationalInference
qvi = QuantizedVariationalInference(target_log_prob_fn=conditioned_log_prob,
                                            surrogate_posterior=surrogate_posterior,
                                            optimizer=tf.optimizer.Adam(),
                                            num_steps=num_steps,
                                            sample_size=sample_size,
                                            D=D)
qvi.run()
qvi.plot()

Pre-trained Models

Pre-trained models with results can be produced with the scripts in the notebooks' directory . All article's figures are reproductible by running it. Also, HTML and pdf versions of the notebook are available.

Data and Grid Generation

Data used for modelisation is available in the data directory. Grids' directory contains the optimal grid for Normal Distribution in the format N_D_nopti (where N is the number of sample, D the dimension).

Non-optimal grid can be generated with the script generate_normal_grids.sh (R version 4.0 is needed).

cd data
bash generate_normal_grids.sh D N n 

where D is the dimension, N the level of the optimal quantizer and n the number of samples used to produce it (larger is better).

Contributing

See Licence file.

About

This repository is the official implementation of Quantized Variational Inference (NeurIPS 2020).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published