Back to rankings

thu-ml/zhusuan

Pythonzhusuan.readthedocs.io

A probabilistic programming library for Bayesian deep learning, generative models, based on Tensorflow

bayesian-inferenceprobabilistic-programminggraphical-modelsgenerative-modelsdeep-learning
Star Growth
Stars
2.2k
Forks
415
Weekly Growth
Issues
8
1k2k
Jan 2023Mar 2024May 2025Jul 2026
ArtifactsPyPIpip install zhusuan
README

Build Status Doc Status License Join the chat at https://gitter.im/thu-ml/zhusuan

ZhuSuan is a Python probabilistic programming library for Bayesian deep learning, which conjoins the complimentary advantages of Bayesian methods and deep learning. ZhuSuan is built upon TensorFlow. Unlike existing deep learning libraries, which are mainly designed for deterministic neural networks and supervised tasks, ZhuSuan provides deep learning style primitives and algorithms for building probabilistic models and applying Bayesian inference. The supported inference algorithms include:

  • Variational Inference (VI) with programmable variational posteriors, various objectives and advanced gradient estimators (SGVB, REINFORCE, VIMCO, etc.).

  • Importance Sampling (IS) for learning and evaluating models, with programmable proposals.

  • Hamiltonian Monte Carlo (HMC) with parallel chains, and optional automatic parameter tuning.

  • Stochastic Gradient Markov Chain Monte Carlo (SGMCMC): SGLD, PSGLD, SGHMC, and SGNHT.

Installation

ZhuSuan is still under development. Before the first stable release (1.0), please clone the repository and run

pip install .

in the main directory. This will install ZhuSuan and its dependencies automatically. ZhuSuan also requires TensorFlow 1.13.0 or later. Because users should choose whether to install the cpu or gpu version of TensorFlow, we do not include it in the dependencies. See Installing TensorFlow.

If you are developing ZhuSuan, you may want to install in an "editable" or "develop" mode. Please refer to the Contributing section below.

Documentation

Examples

We provide examples on traditional hierarchical Bayesian models and recent deep generative models.

To run the provided examples, you may need extra dependencies to be installed. This can be done by

pip install ".[examples]"
  • Gaussian: HMC
  • Toy 2D Intractable Posterior: SGVB
  • Bayesian Neural Networks: SGVB, SGMCMC
  • Variational Autoencoder (VAE): SGVB, IWAE
  • Convolutional VAE: SGVB
  • Semi-supervised VAE (Kingma, 2014): SGVB, Adaptive IS
  • Deep Sigmoid Belief Networks Adaptive IS, VIMCO
  • Logistic Normal Topic Model: HMC
  • Probabilistic Matrix Factorization: HMC
  • Sparse Variational Gaussian Process: SGVB

Citing ZhuSuan

If you find ZhuSuan useful, please cite it in your publications. We provide a BibTeX entry of the ZhuSuan white paper below.

@ARTICLE{zhusuan2017,
    title={Zhu{S}uan: A Library for {B}ayesian Deep Learning},
    author={Shi, Jiaxin and Chen, Jianfei. and Zhu, Jun and Sun, Shengyang
    and Luo, Yucen and Gu, Yihong and Zhou, Yuhao},
    journal={arXiv preprint arXiv:1709.05870},
    year=2017,
}

Contributing

We always welcome contributions to help make ZhuSuan better. If you would like to contribute, please check out the guidelines here.

Related repositories
ddbourgin/numpy-ml

Machine learning, in numpy

PythonPyPIGNU General Public License v3.0machine-learningneural-networks
numpy-ml.readthedocs.io
16.3k3.8k
pymc-devs/pymc

Bayesian Modeling and Probabilistic Programming in Python

PythonPyPIOtherpythonstatistical-analysis
pymc.io
9.7k2.3k
pyro-ppl/pyro

Deep universal probabilistic programming with Python and PyTorch

PythonPyPIApache License 2.0pythonpytorch
pyro.ai
9k1k
sahibzada-allahyar/YC-Killer

A library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and apply using the link in the readme to join our open source AI research team.

TypeScriptnpmphysicslean
forms.gle/iQJ15xsvb9LZhPaNA
2.8k125
stan-dev/stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.

C++BSD 3-Clause "New" or "Revised" Licensestanbayesian-inference
mc-stan.org
2.8k382
pyro-ppl/numpyro

Probabilistic programming with NumPy powered by JAX for autograd and JIT compilation to GPU/TPU/CPU.

PythonPyPIApache License 2.0pyrojax
num.pyro.ai
2.7k295
mckinsey/causalnex

A Python library that helps data scientists to infer causation rather than observing correlation.

PythonPyPIOthercausal-inferencecausal-models
causalnex.readthedocs.io
2.5k289
google/neural-tangents

Fast and Easy Infinite Neural Networks in Python

Jupyter NotebookApache License 2.0neural-networksinfinite-networks
iclr.cc/virtual_2020/poster_SklD9yrFPS.html
2.4k240
avehtari/BDA_course_Aalto

Bayesian Data Analysis course at Aalto

TeXbayesbayesian
avehtari.github.io/BDA_course_Aalto/
2.3k568
TuringLang/Turing.jl

Bayesian inference with probabilistic programming.

JuliaMIT Licensemachine-learningprobabilistic-programming
turinglang.org
2.2k241
pymc-devs/pymc-resources

PyMC educational resources

Jupyter NotebookMIT Licensebayesian-inferencebayesian-statistics
2.1k762
JavierAntoran/Bayesian-Neural-Networks

Pytorch implementations of Bayes By Backprop, MC Dropout, SGLD, the Local Reparametrization Trick, KF-Laplace, SG-HMC and more

Jupyter NotebookMIT Licensedeep-learningbayesian-inference
2k305