What's the difference between mask and block?


It seems that mask sets the log prob to 0 for the masked sample site, and block hides this sample site totally.
So i believe block should be used when we don’t want to infer the sample site, but what’s the intended use of mask? If we fix the log prob to 0, the inference algo can’t infer the posterior either, so why differentiate between them?


poutine.mask(mask=False) zeros out log_prob terms in the trace, but preserves the (reparametrized) value of the sample site. By contrast poutine.block removes the entire sample site, including the sampled value. In cases like prediction where you’re interested in the sampled value but not in the density, you can use mask to reduce computation but still get the sampled value.

Note also mask has no effect on param or other Pyro statements, it only affects pyro.sample statements. By contrast block can block any sort of pyro statement, including pyro.param or custom statements.

Thanks for the clear reply! I understand it now.