TensorFlow probability c.f. Stan / comment

I have just joined a new group with a new employer, and the manager of this group is keen to have everything done in Python. I don’t find this ideal, but I understand his motivation, and it’s not worth pushing back on; i.e. I can live with it. However, I expect a lot of the work to involve probabilistic programming. I have explained that while this, yes, would likely be done in Stan, we can use Stan through PyStan, which keeps at lest within the letter of the guidelines (I have no experience with PyStan, but I am sure it is OK).

However, he immediately mentioned TensorFlow Probability. I think he is under the impression that this is a more authentically Python native package. I’m not interested in pushing back on this idea, however I’m interested to know how it compares to Stan as a general tool for building generative bayesian modelling. I don’t want to be stuck with bad tools, obviously.

I have no opinion about this. I don’t know it (it has autodiff, which is good, allows, HMC, etc. but it does seem to be focussed on probabilistic deep learning, an area about which i know very little). I have just looked briefly at it, and all I see is the standard mess of python library calls, which are not to my taste, but if this is only a superficial complaint about syntax, I can live with it.

Thus, anybody have, or know where I can find, informed technical comparison. Or alternatively, does anyone have a one-line dismissal, or endorsement, etc…

All comments welcome.


Sean Matthews


It seems that Matt Hoffman is working in TFP these days and just published a really exciting HMC variant that scales super well on GPUs.


There are couple of ways working ppl in python.


PyStan / CmdStanPy
pyro (pytorch)
tfp (tensorflow)

It is more of a question what kind of problem you need to solve.

All these libs work together with ArviZ InferenceData for post processing.

I would say that Stan is probably fastest when it comes to mcmc speed (for most problems).


I have used both Stan and TFP quite a bit in the last few years so might be able to help a little. I prefer TFP these days as i find it much easier to debug and interact with my models. TFP is currently much lower level but that is being worked on currently. So you might find yourself having to write more code in some cases, most of which will be boilerplate. I’ve written a little about how they compare on my blog but it’s hard to keep up to date and your problems might be totally different.

Hope it is ok to post it here: Bayesian workflow with TFP and arviz


Thanks for that. Shall read with interest.



1 Like