Skip to content

Bayesian Neural Network in PyTorch

License

Notifications You must be signed in to change notification settings

anassinator/bnn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bayesian Neural Network

https://travis-ci.org/anassinator/bnn.svg?branch=master

This is a Bayesian Neural Network (BNN) implementation for PyTorch. The implementation follows Yarin Gal's papers "Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning" (see BDropout) and "Concrete Dropout" (see CDropout).

This package was originally based off the work here: juancamilog/prob_mbrl.

Install

To install simply clone and run:

python setup.py install

You may also install the dependencies with pipenv as follows:

pipenv install

Finally, you may add this to your own application with either:

pip install 'git+https://github.com/anassinator/bnn.git#egg=bnn'
pipenv install 'git+https://github.com/anassinator/bnn.git#egg=bnn'

Usage

After installation, import and use as follows:

import bnn

You can see the examples directory for some Jupyter notebooks with more detailed examples.

The following is an example of what this BNN was able to estimate with a few randomly sampled points (in red) of a noisy sin function. The dotted curve represent the real function that was kept a secret from the model, whereas the black line and the grey area represent the estimated mean and uncertainty.

Bayesian neural network estimate of sin(x)

Contributing

Contributions are welcome. Simply open an issue or pull request on the matter.

Linting

We use YAPF for all Python formatting needs. You can auto-format your changes with the following command:

yapf --recursive --in-place --parallel .

You can install the formatter with:

pipenv install --dev

License

See LICENSE.