I am trying to run a fairly simple MCMC sample for some time series data. I believe I am including all the required args, but I'm still getting an error.
The library versions:
tensorflow==1.14.0
tensorflow-proability==0.7.0
I tried rolling back to tfp 0.6.0 and got a matmul
error. I tried pushing forward to tf nightly and got the same error as below.
The code
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
tf.enable_eager_execution()
rate_prior = tfd.Exponential(1./mean_users)
users_before = [...] # bogus positive ints
users_after = [...] # bogus positive ints
def unnormalized_log_prob(rate_before, rate_after):
users_before_prior = tfd.Poisson(rate_before)
users_after_prior = tfd.Poisson(rate_after)
return (rate_prior.log_prob(rate_before)
+ rate_prior.log_prob(rate_after)
+ tf.reduce_sum(users_before_prior.log_prob(users_before))
+ tf.reduce_sum(users_after_prior.log_prob(users_after))
)
bijectors = [tfp.bijectors.Exp, tfp.bijectors.Exp]
hmc = tfp.mcmc.TransformedTransitionKernel(
tfp.mcmc.HamiltonianMonteCarlo(
target_log_prob_fn=unnormalized_log_prob,
step_size=10.,
num_leapfrog_steps=3,
),
bijectors
)
states = tfp.mcmc.sample_chain(
num_results=10000,
current_state=[tf.ones(2) * mean_users],
kernel=hmc,
trace_fn=None
)
This returns an error.
.../tensorflow_probability/python/mcmc/transformed_kernel.py in <listcomp>(.0)
71 def fn(state_parts):
72 return [b.inverse(sp)
---> 73 for b, sp in zip(bijector, state_parts)]
74 return fn
75
TypeError: inverse() missing 1 required positional argument: 'y'`
Try
bijectors = [tfp.bijectors.Exp(), tfp.bijectors.Exp()]
]