The code:
# Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
This example shows how to marginalize out discrete model variables in Pyro.
This combines Stochastic Variational Inference (SVI) with a
variable elimination algorithm, where we use enumeration to exactly
marginalize out some variables from the ELBO computation. We might
call the resulting algorithm collapsed SVI or collapsed SGVB (i.e
collapsed Stochastic Gradient Variational Bayes). In the case where
we exactly sum out all the latent variables (as is the case here),
this algorithm reduces to a form of gradient-based Maximum
Likelihood Estimation.
To marginalize out discrete variables ``x`` in Pyro's SVI:
1. Verify that the variable dependency structure in your model
admits tractable inference, i.e. the dependency graph among
enumerated variables should have narrow treewidth.
This file has been truncated. show original
I noticed that when sample transition and emission from the Dirichlet distribution, you applied this:
with poutine.mask(mask=include_prior) , the include_prior is True here.
what is the mask=True doing here? Is it ok just removing this line.
When include_prior == False
, the log-probabilities of the sample sites inside that mask
context are set to 0 . This is used in the same file to evaluate the marginal likelihood of held-out data given the MAP values of the parameters. When include_prior == True
, the model is equivalent to the same model with no mask
context.