tensorflow / probability

Probabilistic reasoning and statistical analysis in TensorFlow
https://www.tensorflow.org/probability/
Apache License 2.0
4.27k stars 1.11k forks source link

Tutorial request: simple gibbs sampling #369

Open mberaha opened 5 years ago

mberaha commented 5 years ago

I usually code my MCMC algorithms (mostly gibbs in BNP) in C++, but this time I thought I might switch to tfp for a change. Is there anyone using tfp for (blocked) gibbs sampling / some resources online?

Thank you

SiegeLordEx commented 5 years ago

Heya @mberaha,

Currently there's no easy way to accomplish Gibbs sampling of any sort in TFP, you'd effectively need to implement a new TransitionKernel which does the overall transition you're interested in. We are very interested in adding some sort of blocked Gibbs, mostly focusing on Metropolis-Hastings-Within-Gibbs use case. Roughly speaking, we're thinking requiring the user to partition their state and then assign a transition operator for each partition: then we'll be able to take a single joint log probability function and alternate between the multiple transitions that way. Would that be sufficient for your use case? Do you need exact transitions as well (for proper blocked Gibbs sampling)?

mberaha commented 5 years ago

Hey @SiegeLordEx, thanks a lot for your reply!

I think your idea is great, and would be very interesting to use. On my side, most of the times I have access to the full conditionals (but mainly bc of laziness), still I think that having a Metropolis-Hastings-Within-Gibbs tutorial would really help me to understand better how tfp works :)

jguan1 commented 5 years ago

Hi @SiegeLordEx , I'm also very interested in using tfp for Metropolis-Hastings-Within-Gibbs. Is there any tutorial for that? Or are there any good tutorials on developing TransitionKernel that you mentioned earlier? I'm sill very new to tfp, but very excited in learning its functionalities.

junpenglao commented 5 years ago

For MH within Gibbs, you can see this answer: https://github.com/tensorflow/probability/issues/495 where @SiegeLordEx sketched how you would go about to implement something like that.

coatless commented 3 years ago

@chrism0dwk has proposed an implementation in #1233. It's currently waiting on review.