Coder Social home page Coder Social logo

bayesian-neural-network-pytorch's Introduction

Bayesian-Neural-Network-Pytorch

MIT License Pypi Documentation Status

This is a lightweight repository of bayesian neural network for PyTorch.

Usage

📋 Dependencies

  • torch 1.2.0
  • python 3.6

🔨 Installation

  • pip install torchbnn or
  • git clone https://github.com/Harry24k/bayesian-neural-network-pytorch
import torchbnn

🚀 Demos

  • Bayesian Neural Network Regression (code): In this demo, two-layer bayesian neural network is constructed and trained on simple custom data. It shows how bayesian-neural-network works and randomness of the model.
  • Bayesian Neural Network Classification (code): To classify Iris data, in this demo, two-layer bayesian neural network is constructed and trained on the Iris data. It shows how bayesian-neural-network works and randomness of the model.
  • Convert to Bayesian Neural Network (code): To convert a basic neural network to a bayesian neural network, this demo shows how nonbayes_to_bayes and bayes_to_nonbayes work.
  • Freeze Bayesian Neural Network (code): To freeze a bayesian neural network, which means force a bayesian neural network to output same result for same input, this demo shows the effect of freeze and unfreeze.

Citation

If you use this package, please cite the following BibTex (SemanticScholar, GoogleScholar):

@article{lee2022graddiv,
  title={Graddiv: Adversarial robustness of randomized neural networks via gradient diversity regularization},
  author={Lee, Sungyoon and Kim, Hoki and Lee, Jaewook},
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
  year={2022},
  publisher={IEEE}
}

🔎 Update Records

Here is update records of this package.

Thanks to

bayesian-neural-network-pytorch's People

Contributors

harry24k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bayesian-neural-network-pytorch's Issues

Initialization and reparameterization

self.weight_log_sigma.data.fill_(self.prior_log_sigma)
.

  1. Excuse me, is it necessary to use "fill_(self.prior_log_sigma)" to initialize the posterior sigma in BNN? Can it be changed? Does it conform to BNN theory if it is changed?

weight = self.weight_mu + torch.exp(self.weight_log_sigma) * torch.randn_like(self.weight_log_sigma)

2. Must this method be used in reparameterization techniques? That is z=u+exp(sigma)*eps. Can this reparameterized calculation method be changed? Is it consistent with BNN theory after the change?

Great work!

Hi Harry,

It is nice to see your work on designing modules for building BNNs. I have checked the codes and I am impressive. I appreciate it if you could share with me the testing code to build and train a simple BNN with these codes. Thanks a lot!

Zhijie

literature reference

Hi,

Thanks for your work! This library is easy to use and works well on my dataset(big and complex).

Since I am new to BNN, could you please share with me the paper(s) corresponding to your implementation?

初始化方法的变化

初始化方法normal_(0, stdv)替换了uniform_(-stdv, stdv)对整个贝叶斯神经网络的理论有什么影响吗?

Uncertainty estimation

Hi,

I am interested in using BNN for uncertainty estimation instead of just expecting a random output every time. Do you have a demo showing how the uncertainty can be computed? With your code, would it possibly be like using dropout and doing inference multiple times, then computing the variance of the multiple outputs?

Thanks

BNN and L2

Excuse me, what is the difference between BNN and L2 regular?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.