【问题标题】:How to do mixed sampling in TensorFlow如何在 TensorFlow 中进行混合采样
【发布时间】:2020-05-05 09:16:55
【问题描述】:

我正在使用 TensorFlow Probability 的 MCMC 包实现复杂的采样算法。假设我对一个组件使用 Gibbs 抽样,对另一个组件使用 Hamiltonian Monte Carlo,最后是 Random Walk Metropolis。例如,假设我们有一个联合概率,

p(X|a, b)p(b|c, d)p(c)p(d)p(a).

我的自定义采样迭代大致是:


def one_iteration():
   # Sampling `a`: 
   # part of joint density: p(X|a, b)p(a)
   # ...using some custom Gibbs sampler

   # Sampling `b`:
   # part of joint density: p(X|a, b)p(b|c, d)

   def log_prob(b):
      return p(X|a, b).log_prob() + p(b|c, d).log_prob(b)

   hmc = tfp.mcmc.HamiltonianMonteCarlo(
      log_prob, step_size=0.1, num_leapfrog_steps=3)
   samples, is_accepted = tfp.mcmc.sample_chain(
      num_results=1,
      num_burnin_steps=0,
      current_state=b,
      kernel=hmc)

   # Sampling `c`:
   # part of joint density: p(b|c, d)p(c)

   def log_prob(c):
      return p(b|c, d).log_prob() + p(c).log_prob(c)

   rwm = tfp.mcmc.RandomWalkMetropolis(log_prob)
   samples, is_accepted = tfp.mcmc.sample_chain(
      num_results=1,
      num_burnin_steps=0,
      current_state=c,
      kernel=rwm)

然后运行:

for i in range(T):
   one_iteration()

这是混合采样的正确方法吗?即每个组件采样算法的每次迭代都调用sample_chain

【问题讨论】:

    标签: python tensorflow mcmc tensorflow-probability


    【解决方案1】:

    有点可能。有关 Gibbs 中 Metropolis 的讨论,请参阅此 PR。对 PR 的投票将提高 MwG 的受欢迎程度,并有望得到实施。

    https://github.com/tensorflow/probability/pull/1233

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-05
      • 2018-06-27
      • 1970-01-01
      • 2015-05-26
      • 1970-01-01
      • 2014-10-10
      相关资源
      最近更新 更多