Hello, I am trying HMC inference on simple Beta-Bernoulli model, but it seems doesn’t work. I get correct samples from Beta distributed variable, but posteriors from Empirical variable are not in [0;1] rage, they are negative in most cases.
import edward as ed
import tensorflow as tf
from edward.models import (
Beta,
Bernoulli,
Empirical
)
x_prob = Beta(0.3, 1.0)
x = Bernoulli(probs=x_prob)
qx_prob = Empirical(params=tf.Variable(tf.zeros(10)))
inference = ed.HMC({x_prob: qx_prob}, data={x: 1})
inference.run(n_steps=10)
samples = x_prob.sample(10).eval()
print("samples: " + str(samples))
params = qx_prob.params.eval()
print("params: " + str(params))
mean = qx_prob.mean().eval()
print("mean: " + str(mean))
Output sample:
samples: [ 0.08889898 0.00208424 0.5681445 0.01588311 0.01571349 0.00344653 0.20849131 0.05374139 0.34170994 0.17989925]
params: [-1.26416469 -1.35929894 -1.35929894 1.10303259 1.10303259 0.05707812 -3.77804422 -3.77804422 -1.0335499 -0.17189652]
mean: -1.04812