All Projects → ksachdeva → Rethinking Tensorflow Probability

ksachdeva / Rethinking Tensorflow Probability

Licence: apache-2.0
Statistical Rethinking (2nd Ed) with Tensorflow Probability

Projects that are alternatives of or similar to Rethinking Tensorflow Probability

Celeste.jl
Scalable inference for a generative model of astronomical images
Stars: ✭ 142 (-6.58%)
Mutual labels:  jupyter-notebook, bayesian-inference, variational-inference
Rethinking Pyro
Statistical Rethinking with PyTorch and Pyro
Stars: ✭ 116 (-23.68%)
Mutual labels:  jupyter-notebook, bayesian-inference, bayesian-statistics
Bcpd
Bayesian Coherent Point Drift (BCPD/BCPD++); Source Code Available
Stars: ✭ 116 (-23.68%)
Mutual labels:  bayesian-inference, variational-inference, bayesian-statistics
Bayesian Analysis Recipes
A collection of Bayesian data analysis recipes using PyMC3
Stars: ✭ 479 (+215.13%)
Mutual labels:  jupyter-notebook, bayesian-inference, bayesian-statistics
Pytorch Bayesiancnn
Bayesian Convolutional Neural Network with Variational Inference based on Bayes by Backprop in PyTorch.
Stars: ✭ 779 (+412.5%)
Mutual labels:  bayesian-inference, variational-inference, bayesian-statistics
Bayesian Stats Modelling Tutorial
How to do Bayesian statistical modelling using numpy and PyMC3
Stars: ✭ 480 (+215.79%)
Mutual labels:  jupyter-notebook, bayesian-inference, bayesian-statistics
Rethinking Numpyro
Statistical Rethinking (2nd ed.) with NumPyro
Stars: ✭ 225 (+48.03%)
Mutual labels:  jupyter-notebook, variational-inference, bayesian-statistics
Bayesian Neural Networks
Pytorch implementations of Bayes By Backprop, MC Dropout, SGLD, the Local Reparametrization Trick, KF-Laplace, SG-HMC and more
Stars: ✭ 900 (+492.11%)
Mutual labels:  jupyter-notebook, bayesian-inference, variational-inference
Resources
PyMC3 educational resources
Stars: ✭ 930 (+511.84%)
Mutual labels:  jupyter-notebook, bayesian-inference, bayesian-statistics
Pymc3 vs pystan
Personal project to compare hierarchical linear regression in PyMC3 and PyStan, as presented at http://pydata.org/london2016/schedule/presentation/30/ video: https://www.youtube.com/watch?v=Jb9eklfbDyg
Stars: ✭ 110 (-27.63%)
Mutual labels:  jupyter-notebook, bayesian-inference
Firstcoursenetworkscience
Tutorials, datasets, and other material associated with textbook "A First Course in Network Science" by Menczer, Fortunato & Davis
Stars: ✭ 111 (-26.97%)
Mutual labels:  jupyter-notebook, tutorials
Quantum Algorithms Tutorials
Tutorials for Quantum Algorithms with Qiskit implementations.
Stars: ✭ 115 (-24.34%)
Mutual labels:  jupyter-notebook, tutorials
Gpstuff
GPstuff - Gaussian process models for Bayesian analysis
Stars: ✭ 106 (-30.26%)
Mutual labels:  bayesian-inference, variational-inference
Gpflow
Gaussian processes in TensorFlow
Stars: ✭ 1,547 (+917.76%)
Mutual labels:  variational-inference, bayesian-statistics
Lab Workshops
Materials for workshops on text mining, machine learning, and data visualization
Stars: ✭ 112 (-26.32%)
Mutual labels:  jupyter-notebook, tutorials
Awesome Pytorch List Cnversion
Awesome-pytorch-list 翻译工作进行中......
Stars: ✭ 1,361 (+795.39%)
Mutual labels:  jupyter-notebook, tutorials
Neural Tangents
Fast and Easy Infinite Neural Networks in Python
Stars: ✭ 1,357 (+792.76%)
Mutual labels:  jupyter-notebook, bayesian-inference
A Nice Mc
Code for "A-NICE-MC: Adversarial Training for MCMC"
Stars: ✭ 115 (-24.34%)
Mutual labels:  jupyter-notebook, bayesian-inference
Bayes By Backprop
PyTorch implementation of "Weight Uncertainty in Neural Networks"
Stars: ✭ 119 (-21.71%)
Mutual labels:  jupyter-notebook, variational-inference
Normalizing Flows
Understanding normalizing flows
Stars: ✭ 126 (-17.11%)
Mutual labels:  jupyter-notebook, variational-inference

Statistical Rethinking (2nd Edition) with Tensorflow Probability

This repository provides jupyter notebooks that port various R code fragments found in the chapters of Statistical Rethinking 2nd Edition by Professor Richard McElreath to python using tensorflow probability framework.

Note - These notebooks are based on the 8th December 2019 draft. I will update the notebooks once the book is released.

Misc Notes

  • Why Tensorflow Probability ? There are many great probabilitic frameworks (PPLs) out there. I especially like Numpyro & PyMC3 (& PyMC4). There are 2 main reasons why I chose to do this exercise in tfp.

    • First and main reason is to not use the magic of the libraries. Sometimes higher level libraries hide the details which are necessary for one to truly understand the subject. As a matter of fact, working with TFP has resulted in me becoming more appreciable of these high level libraries as indeed they not only provide great helpers but make the code easy to read and reuse.
    • Second is that I have other investments in Tensorflow ecosystem so am not keen on switching to pyTorch even though I really like what Pyro team has done. I am hoping that PyMC4 will be a great alternative.

    For production use, I strongly recommend that one must use these higher level libraries i.e. Numpyro, PyMC3, PyMC4

  • What worked ? Well of course this book is the best there is in this area. The community is also great. I got quick responses from tensorflow probability team whenever I asked questions on tfp google group.

  • What was hard ? It may be tad bit subjective because I am challenged when it comes to manipulating shapes (high dimensional arrays). I find numpy to be difficult and tensorflow is way more harder when it comes to working with multi-dimensional arrays. This is one of the main problems I have faced and continue to face. Another problem is that the stack trace generated by TFP can be really difficult to understand. This mostly is the side effect of graphs that make debugging difficult. Quite often as long as I used only 1 chain things would work but working with multiple chains require that you pay special attention to the shapes/batches of the various tensors/distributions.

  • Visualization I have made use of arviz and in order to do that I converted the output of various sampling procedures to the format/structure required by it. This made me learn and discover xarray. It was really worth doing it and made it easy to plot the graphs.

Work Remaining/Pending/TODO

There are few code cells in various notebooks that are still not working. I do plan to investigate & fix/finish them. Chapter 14 in particular is not working. Any help is appreciated.

In majority of the chapters, the book has used quadratic approximation (quap) where as I have used HMC everywhere. I plan to change this as well by implementing Quadratic/Laplace approximation.

Chapters

If you prefer the readonly view of notebooks (html pages) then use this link - https://ksachdeva.github.io/rethinking-tensorflow-probability/

If you want to run the notebooks locally -

# install the requirements
pip install -r requirements.txt
# install jupyter in your virtual environment
pip install -r requirements-extra.txt

If you prefer to run the notebooks in binder then click here Binder

Clicking on the links will open the notebooks in Google Colab

Acknowledgements

My immense gratitude goes to Professor Richard McElreath for writing such a wonderful book. His method of teaching has made somewhat difficult subject of Bayesian Statistics approachable, interesting and to some extent fun as well. We need more educators like you Sir !.

Another person I want to thank is Du Phan (https://github.com/fehiepsi). He is the main author of Numpyro, a great framework to do Bayesian Analysis. He has ported Statsical Rethinking (2nd Ed) to Numpyro and his notebooks were not only insipirational but were also of great help to me in creating graphs. I borrowed most of his code fragments when it came to plotting the figures using matplotlib.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].