Generate samples using model function itself?

To do inference, I created a model(data) and guide(data), where data is the observed data.
Thus my model(data) contains the line: pyro.sample(‘obs’, dist.Normal(mu,1.), obs=data).
Then when I call log_prob_sum(), this will compute using the observed data.

However, I also would like to simulate some data by sampling from the model p(z,x), then compute log p(z,x):
Do I need to create a separate function without ‘obs=data’ (to generate z,x and then call log_prob_sum()?)
or is there a way that I can re-use model(data) while ignoring the observed data, to sample z,x and then compute log p(z,x)?

Could you please provide some code samples? thank you!

if i understand your question you want to take a look at uncondition: http://docs.pyro.ai/en/stable/poutine.html#pyro.poutine.handlers.uncondition

unconditioned_model = poutine.uncondition(model)

1 Like

Thank you very much @martinjankowiak, this works! :smile:
I see it will ignore the data values in obs=data, and sample from the distribution.