TransformedTransitionKernel 无法在 sample_chain 中应用逆双射器

TransformedTransitionKernel fails to apply inverse bijector in sample_chain

我正在尝试 运行 一些时间序列数据的相当简单的 MCMC 示例。我相信我包含了所有必需的参数,但我仍然遇到错误。

库版本:

tensorflow==1.14.0
tensorflow-proability==0.7.0

我尝试回滚到 tfp 0.6.0,但出现 matmul 错误。我试着推进到 tf nightly 并得到了与下面相同的错误。

代码

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
)

这 returns 一个错误。

.../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'`

尝试

bijectors = [tfp.bijectors.Exp(), tfp.bijectors.Exp()]]