I am trying to use Pyro for modeling bayesian networks. I am very new and was looking at the introductory tutorials where you have the following model:
def weather():
cloudy = pyro.sample('cloudy', pyro.distributions.Bernoulli(0.3))
cloudy = 'cloudy' if cloudy.item() == 1.0 else 'sunny'
mean_temp = {'cloudy': 55.0, 'sunny': 75.0}[cloudy]
scale_temp = {'cloudy': 10.0, 'sunny': 15.0}[cloudy]
temp = pyro.sample('temp', pyro.distributions.Normal(mean_temp, scale_temp))
return cloudy, temp.item()
Here the temperature
is conditioned in cloudy
. Now imagine we have another parent which is also discrete called pressure
and it can be something similar as:
pressure = pyro.sample('pressure', pyro.distributions.Bernoulli(0.3))
pressure = 'high' if pressure.item() == 1.0 else 'low'
Now, I want to also condition temperature
on this pressure
variable. How should the mean_temp
and scale_temp
be defined for this additional parent relationship.
In my model, I have 3 parents (each with 9 possible states) which connect to various such continuous nodes and I am trying to figure out how to efficiently set it up with pyro (but getting lost in the abstraction). Later, I want to present evidence to this model and estimate these parameters from data.