In a simple LDA model, I subsample the corpus in the guide:
for doc in pyro.plate("corpus", num_docs, subsample_size=50):
theta = pyro.sample("topic_dist_for_doc_{}".format(doc), dist.Dirichlet(alpha))
In the model, the corresponding part is:
for doc in pyro.plate("corpus", num_docs):
theta = pyro.sample("topic_dist_for_doc_{}".format(doc), dist.Dirichlet(alpha))
with pyro.plate("words_{}".format(doc), num_words_per_doc[doc]):
z = pyro.sample("topic_for_word_{}".format(doc), dist.Categorical(theta), infer={"enumerate": "parallel"} )
pyro.sample("word_for_position_{}".format(doc), dist.Categorical(beta[z]), obs = data[doc])
When I use pyro.infer.Predictive to get the sample
It gives the error KeyError: ‘topic_dist_for_doc_137’.
I think there is a communication problem between guide and model when using Predictive function. This is probably the same issue with https://forum.pyro.ai/t/pyro-infer-predictive-with-dynamic-model-structure/1958 .
Am I doing something or is this a bug in Pyro?
Also, there is another issue apart from predictive, if I do not use subsampling (it should be subsample<63) then (I think) because of how Pyro handles tensor shapes in collapsing variables (as explained in enumeration ) in this part I get an error due to enumerate indicating pytorch does not support dim>=64
z = pyro.sample("topic_for_word_{}".format(doc), dist.Categorical(theta), infer={"enumerate": "parallel"} )
Since when model is called in SVI, in each step of for doc in pyro.plate("corpus", num_docs):
it creates a growing nested list for the next “topic_for_word_{}” .
In here, I also have the same question
Am I doing something or is this a bug in Pyro?
Thanks in advance.