When should we use poutine.block and for what types of variables we should hidden or expose?

I noticed that the poutine.block is very important for many models (e.g. the code below) by checking all the tutorial articles. But it is still not clear, when should we use it and how?

# Gaussian Mixture Model

K = 2  # Fixed number of components.

def model(data):
    # Global variables.
    weights = pyro.sample('weights', dist.Dirichlet(0.5 * torch.ones(K)))
    scale = pyro.sample('scale', dist.LogNormal(0., 2.))
    with pyro.plate('components', K):
        locs = pyro.sample('locs', dist.Normal(0., 10.))

    with pyro.plate('data', len(data)):
        # Local variables.
        assignment = pyro.sample('assignment', dist.Categorical(weights))
        pyro.sample('obs', dist.Normal(locs[assignment], scale), obs=data)

global_guide = AutoDelta(poutine.block(model, expose=['weights', 'locs', 'scale']))

The API document of poutine.block is too technical and not friendly for users who just want to focus on building their own model straightforwardly.

Is there a better and easy-understand way to understand the use of poutine.block?

1 Like

see this response

1 Like

Thank you very much for linking the post. :grinning: