Ignore certain parameters when calculating ELBO

Hi al!

I was wondering if it’s possible in pyro to have a model where some of the sampled parameters are not taken into account while calculating the ELBO, because there’s no need to infer them, but they just have to be randomly sampled from their prior while other parameters are optimized.


The main two methods of ignoring ELBO terms are:

  • poutine.mask to set an ELBO term to zero, but still infer the posterior distribution.
    with poutine.mask(mask=False):
        x = pyro.sample("hidden", dist.Normal(0, 1))
  • poutine.block to totally block Pyro’s view of a sample site. This is equivalent to randomly generating data each time you run the model, effectively doing minibatch training on an infinite dataset. Beware this will negate some of the benefit of inference with vectorized particles (if you’re vectorizing), since it blocks the vectorized particle plate and you’ll draw only a single sample per training step.
    with poutine.block():
        x = pyro.sample("hidden", dist.Normal(0, 1))

IIUC you’re looking for the second approach, poutine.block. Alternatively you could simply call my_distribution.sample() without wrapping it in a pyro.sample statement.

x = dist.Normal(0,1).sample()
1 Like