Reputation: 9
I am new to Tensorflow and I want to multiply two distributions to get posterior density. How can I do it using tensorflow?
For example:
likelihood = tf.contrib.distributions.MultivariateNormalDiag(loc = [0., 0., 0.], scale_diag= [1., 1., 1.])
prior = tf.contrib.distributions.MultivariateNormalDiag(loc = [0., 0., 0.], scale_diag= [1., 1., 1.])
I tried using tf.multiply(likelihood,prior)
but it gives me datatype error
Failed to convert object of type to Tensor. Contents: tf.distributions.MultivariateNormalDiag("MultivariateNormalDiag", batch_shape=(), event_shape=(3,), dtype=float32). Consider casting elements to a supported type.
Can anyone please help me with this.
Help much appreciated. Thanks
Upvotes: 0
Views: 413
Reputation: 161
A tf.distribution
is an object, and hence can not be used as a Tensor.
You can instead multiply (or sum) the .prob
(.log_prob
) methods.
Upvotes: 1