Hi There! I was also looking for a way to build that model and do simple inference on it, for instance the p(R=T|G=T).

The way I was able to make it work is this:

```
rain = edm.Bernoulli(probs=0.2)
p_sprinkler = tf.where(tf.cast(rain, tf.bool), 0.01, 0.4)
sprinkler = edm.Bernoulli(probs=p_sprinkler)
p_grass_wet = tf.where(tf.cast(rain, tf.bool),
tf.where(tf.cast(sprinkler, tf.bool), 0.99, 0.8),
tf.where(tf.cast(sprinkler, tf.bool), 0.9, 0.00000001))
grass_wet = edm.Bernoulli(probs=p_grass_wet)
# Inference
q_rain = edm.Bernoulli(probs=tf.nn.sigmoid(tf.Variable(tf.random_normal([]))))
ed.get_session()
inf = edi.KLpq({rain: q_rain}, data={grass_wet: tf.constant(1, dtype=tf.int32)})
inf.run(n_samples=50)
print(q_rain.probs.eval())
```

For the complete working code check:

https://notebooks.azure.com/janislavjankov/libraries/shared/html/edward-sprinkler.ipynb

Not sure if this is the correct way but it’s working.

Another approach would be to just sample [rain, grass_wet] and compute the conditional probability by counting the results, essentially applying the conditional probability formula p(r=t|g=t) = p(r=t, g=t) / p(g=t) but using the approximated (through the sampling) probabilities. But this is not really using any inference algorithms that Edward provides.