Cannot correctly setup model for Gibbs inference


#1

I created a simple model where runny nose probability depends on cold disease, but the model doesn’t work correctly for some reason, evaluated cold probability doesn’t depend on passed runny nose data.

import edward as ed
import tensorflow as tf
from edward.models import (
	Beta,
	Bernoulli,
	Empirical
)

N = 100

cold_p = Beta(.01, 1.0)
cold = Bernoulli(probs=cold_p)

runny_nose_p_a = tf.cond(tf.cast(cold, tf.bool), lambda: tf.constant(5.0), lambda: tf.constant(.01))
runny_nose_p = Beta(runny_nose_p_a, 1.0)
runny_nose = Bernoulli(probs=runny_nose_p)

q_cold_p = Empirical(params=tf.Variable(tf.zeros(N)))
q_cold = Empirical(params=tf.Variable(tf.zeros(N, dtype=tf.int32)))

q_runny_nose_p = Empirical(params=tf.Variable(tf.zeros(N)))

laten_vars = {cold_p: q_cold_p, cold: q_cold, runny_nose_p: q_runny_nose_p}
inference = ed.Gibbs(laten_vars, data={runny_nose: 1})
inference.run()

mean = q_cold_p.mean().eval()
print("mean: " + str(mean))