PySGMCMC is a Python package that enables users to fit Bayesian models using Markov chain Monte Charlo (MCMC) sampling methods in settings where only noisy gradient information is available.

Due to the stochastic nature of the gradient, these methods are also called Stochastic Gradient Markov Chain Monte Carlo (SGMCMC) methods.

One particular target audience for our samplers are Bayesian Deep Learning practitioners. In Bayesian Deep Learning datasets quickly become large, which makes it intractable to compute the gradient of a model on the whole dataset. A common remedy for this is to sub-sample the dataset into (mini-) batches.


  • Modern MCMC solutions applicable when fitting Bayesian models to sub-sampled datasets.
  • Tensorflow as the computational backend, which allows for efficient numeric calculation, possibly on GPUs and automatic gradient calculation.
  • Flexible: painless application of any of our samplers to your estimation problem.