tensorflow / probability

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

Provide methods to access the RandomVariable in model #196

Closed yaochitc closed 5 years ago

yaochitc commented 5 years ago

Tfp provides concepts like RandomVariable to build the probabilistic model, but it seems impossible to access these RVs after the model is built. When I need to sample from the rv in the model(prior or posterior), I'm not sure how to do. I've checked the codes of the model construction, I'm not sure if it is possible to provide a method to get the model structure through the interceptor method(as how the make_log_joint_fn is implemented).

csuter commented 5 years ago

Hi @yaochitc, check out the tape interceptor defined in the edward2 library (I think it's in interceptor.py). There's also an example of using it in the "LDA using edward2" example: https://github.com/tensorflow/probability/blob/master/tensorflow_probability/examples/latent_dirichlet_allocation_edward2.py

yaochitc commented 5 years ago

ok, thank you.