Samples from prior distribution

if your model has return values you can directly call it and get those:

def model():
    pyro.sample("z", ...)
    x = pyro.sample("x", ...)
    return x

x = model()

of course this will only get you the returned site(s). if you want all the sites, you can use pyro.poutine.trace:

model_trace = pyro.poutine.trace(model).get_trace(model_args)

# inspect the structure of model_trace to pull out what you want, e.g.
for name, site in model_trace.nodes.items():
    if site["type"] == "sample":
        print(name, site["value"])
1 Like