Is it possible to construct a Bayesian network with Pyro?

Yes. Bayes nets can be viewed as probabilistic programs with only assignment statements, no control flow. For example your model would be written:

def model(observed_y):
    x = pyro.sample("x", dist.Normal(mu, theta))
    e = pyro.sample("e", dist.Normal(f(x), g(x)))
    pyro.sample("y", dist.Normal(h(x, e), m(x, e)), obs=observed_y)

Then you could use Pyro’s HMC or SVI (with guide = AutoDiagonalNormal(model)) to perform posterior inference of p(x|y) (I assume you mean p(x|y) rather than p(y|x)).

1 Like