Skip to content

Gradient descent methods for Bayesian variational inference with mean field approximation.

License

Notifications You must be signed in to change notification settings

stephenslab/gradvi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GradVI - Gradient Descent Variational Inference

GradVI provides tools for Bayesian variational inference using gradient descent methods. It is a modular software which provides the boilerplate for variational inference. The user specifies a prior family of distribution and a task (e.g. linear regression, trendfiltering), observes data and runs posterior inference. The goal is to learn the parameters of the corresponding variational posterior family.

Currently, two different prior distributions, namely (1) adaptive shrinkage (ASH) prior, and (2) point-normal prior are provided within the software. For any other choice, the user has to define the prior distribution following the examples provided within the framework.

Related software

  • mr.ash.alpha A coordinate ascent algorithm for multiple linear regression with ASH prior.
  • mr-ash-pen A fast FORTRAN core for GradVI multiple regression using ASH prior.

Theory for GradVI: Link to Overleaf

Installation

The software can be installed directly from github using pip:

pip install git+https://github.com/stephenslab/gradvi

For development, download this repository and install using the -e flag:

git clone https://github.com/stephenslab/gradvi.git # or use the SSH link
cd gradvi
pip install -e .

Quick Start

The software provides several classes for performing variational inference. Try running the following small examples that illustrates using some classes.

Example of Linear regression

Simulate some data:

import numpy as np
from gradvi.priors import Ash
from gradvi.inference import  LinearRegression

n = 100
p = 200
pcausal = 20
s2 = 1.4
k = 10
sk = (np.power(2.0, np.arange(k) / k) - 1)
np.random.seed(100)

X = np.random.normal(0, 1, size = n * p).reshape(n, p)
b = np.zeros(p)
b[:pcausal] = np.random.normal(0, 1, size = pcausal)
err = np.random.normal(0, np.sqrt(s2), size = n)
y = np.dot(X, b) + err

Perform regression:

prior = Ash(sk, scaled = True)
gvlin = LinearRegression(debug = False, display_progress = False)
gvlin.fit(X, y, prior)

b_hat = gvlin.coef

Credits

The GradVI Python package was developed by Saikat Banerjee at the University of Chicago, with contributions from Peter Carbonetto and Matthew Stephens.

About

Gradient descent methods for Bayesian variational inference with mean field approximation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages