So your implementation using Latent
is correct. In Latent
, reparameterize=True is nearly always the best thing to do, to the point where it may not be worth it to include it as an option to not reparamterize. In MarginalSparse
, you’re setting is_observed
, not reparameterize
.
There’s no LatentSparse
implementation in PyMC3 yet, which is what you need. Reading it in the context of what you’re trying to do, the docstring for MarginalSparse
is very much not clear at all about this. There is a PR in progress, which doesn’t use a variational formulation, just the DTC approximation. Also see this gist.