zezo
zezo

Reputation: 455

Tensorflow unnormalized log probabilities

I am using Tensorflow to create some probabilities. I am trying to estimate the unnormalized log probabilities, following the documentation in tensorflow:

import tensorflow_probability as tfp
tfd = tfp.distributions

dist                  = tfd.Normal(loc=0., scale=3.)
sample                = dist.sample([3])
normalized_log_prob   = dist.log_prob(sample)
unnormalized_log_prob = dist.unnormalized_log_prob(sample)

Despite there exist unnormalized_log_prob in the Tensorflow documentation, I have this error:

AttributeError: 'Normal' object has no attribute 'unnormalized_log_prob'

I need a general approach to obtain the unnormalized log probabilites, not just for Normal as I am using Normal just an example.

enter image description here

Upvotes: 0

Views: 315

Answers (1)

Brian Patton
Brian Patton

Reputation: 1076

What does tfp.__version__ tell you? unnormalized_log_prob is only in the latest tensorflow-probability==0.13.0 and tfp-nightly. Also, note that unnormalized_log_prob is currently almost always the same thing as log_prob, except in, say, JointDistributionPinned.

Upvotes: 1

Related Questions