Log pointwise predictive density comes out always 0 in the base ball example

  • What tutorial are you running?
    Baseball example
  • What version of Pyro are you using?
  • Please link or paste relevant code, and steps to reproduce.
    I just copy-pasted the code from the link above, with no changes at all

I was running the above example with no changes to the code and for every time of the model(fully/partially pooled/ with logits) the Log pointwise predictive density comes out to be 0.
That just does not feel right. The fit chances of success might not be the best there, but it is hard to imagine that even in the fully pooled model it is not able to correctly predict any samples.
For example, if we consider a single example with AtBats=6, Hits=0, and a probability of success around 10%(say, normally distributed around that, with small variance), it still seems to have some predictive power?

However, every single model comes out with a density equal to 0.
What am I missing?


I’ve done some basic investigation and figure out that eventually it boils down to the following piece of code in pyro/poutine/trace_struct.py

                    site["unscaled_log_prob"] = log_p
                    log_p = scale_and_mask(log_p, site["scale"], site["mask"])
                    site["log_prob"] = log_p

For whatever reason site["mask"] is set to False which causes that scale and mask function to return zeros. unscaled_log_prob on the other hand contains legitimate non-zero values.

So I guess my question is how come, this site’s mask is set to zero automatically? Any way to change that behavior?

Consequently, I was able to work around that by setting

trace.nodes[MY_SITE]["mask"] = True

It then forces poutine to not null and scale log probabilities, thus resolving the problem.
For me, the question remains if there is a more natural way to do that?

If anyone knows, I’d appreciate an input here