Sample delta vs Deterministic

On the tutorial, line 110, there’s the statement:

pyro.sample("doc_topics", dist.Delta(doc_topics, event_dim=1))

Is that equivalent to doing:

pyro.deterministic("doc_topics", doc_topics, event_dim=1)

If not, when should one be used vs the other?


Good catch, we used to use pyro.Delta to simulate a pyro.deterministic, but it looks like we forgot to update the usage in Feel free to submit a PR :smile:

Just did!


Well, actually it didn’t work… the line with pyro.deterministic("doc_topics", doc_topics, event_dim=1) raises the error

RuntimeError: site doc_topics must be sampled in trace

while pyro.sample("doc_topics", dist.Delta(doc_topics, event_dim=1)) doesn’t…

That’s unexpected, considering that deterministic implementation just calls:

event_dim = value.ndim if event_dim is None else event_dim
return sample(name, dist.Delta(value, event_dim=event_dim).mask(False),
              obs=value, infer={"_deterministic": True})

any clue why it didn’t work?

I think it due to: deterministic is an observed Delta site.

1 Like