Hi all,
I am working on a model that uses a custom point process, and I need to pass some tf variables and Edward distributions, and get a log probability in return to train upon it using KL methods. I do not need to sample from the stochastic process, but just need its log likelihood for training. How do I add that functionality in the class code? I used the function _log_prob
to return the log likelihood, but it doesn’t seem to work.
So it sounds like the final step in your model is a custom probability distribution, rather than one of the built in tf ones that edward alias into RandomVariable
s.
In that case, you’ll need to subclass tf.Distribution
and implement both _sample_n
and _log_prob
, then use that to create a RandomVariable
class. Even though you’re not sampling from it, Edward needs sample
to create a tensor representation of the distribution, which it uses for inference.
Hard to be more specific without a code sample though.
Thank you for replying! It seems that I was naive to just implement an overloading function for _log_prob
in the edward custom RV class. The log probability is the only value I need for training, and all the variables used in it are essentially either tensors or Edward distributions, which are passed int the __init__
function in my class. I used Edward only to refrain from hardcoding VB updates for the graphical model. I guess I will have to write a custom TF class for the process anyway, if that is what you meant to say?