Hi all !
I am very much learning the ropes and just trying out very simple things. For a coin flip model, while using the KLqp inference, the model does not seem to converge. Am I missing/misusing something? Or is there a general reason for the algorithm instability? I am mostly curious from the educational perspective.
NOTE: Using the PointMass+MAP works fine and produces correct result (0.8 in this case)
import tensorflow as tf
import edward as ed
import numpy as np
# Data
data = np.array([1,1,1,1,1,1,1,0,0,1])
# Model
p = ed.models.Beta([2.0], [1.0])
x = ed.models.Bernoulli(probs = tf.ones(10) * p)
# Inference
qp_a = tf.nn.softmax(tf.Variable(tf.random_normal([1])))
qp_b = tf.nn.softmax(tf.Variable(tf.random_normal([1])))
qp = ed.models.Beta(qp_a, qp_b)
inference = ed.KLqp({p: qp}, data={x: data})
inference.run(n_iter = 1000)
print("\nLearnt probability: ", p.eval())
print("\nLearnt (a): ", qp_a.eval())
print("\nLearnt (b): ", qp_b.eval())
Result:
1000/1000 [100%] ██████████████████████████████ Elapsed: 9s | Loss: 9.311
Learnt probability: [0.62244993]
Learnt (a): [1.]
Learnt (b): [1.]