@nicedi I'm using a factor graph model for a problem I'm working on. The model code looks very clean, where I use pyro observe statements for each factor:
x = pyro.sample("x", my_uniform_prior)
pyro.sample("factor_1", dist.Normal(0, 1), obs=some_function_of(x))
pyro.sample("factor_2", dist.Normal(0, 1), obs=another_function_of(x))
Then in my
guide I hand-implement a message passing algorithm to predict a maximum a posteriori
x, sampling it from a
x = pyro.sample("x", dist.Delta(custom_predictor(data)))
This works fine in
pyro.infer.SVI since I can still learn other parts of the mode using variational inference.
The one conceptual downside is that I can no longer sample from the prior by running
model(data). This isn't so bad though, since it would be straightforward conceptually to interpret the model's
obs statements as rejection sampling and draw from the prior using rejection sampling. Or you could draw samples using importance sampling. But in practice I never need to generate data from the prior.