anassinator / bnn

Bayesian Neural Network in PyTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Bayesian Neural Network in PyTorch

License:MIT License


Languages

Language:Python 100.0%