def __init__(self, name, shape, initial_stdev = 2.0, initial_prec = 5.0, a0 = 1.0, b0 = 1.0):
mean_std = 1.0 / np.sqrt(shape[-1])
with tf.variable_scope(name) as scope:
self.mean = tf.Variable(tf.random_uniform(shape, minval=-mean_std, maxval=mean_std))
self.logvar = tf.Variable(np.log(initial_stdev**2.0) * np.ones(shape), name = "logvar", dtype = tf.float32)
self.prec = np.repeat(initial_prec, shape[-1])
self.prec_ph= tf.placeholder(shape=shape[-1], name="prec", dtype = tf.float32)
self.var = tf.exp(self.logvar, name = "var")
self.a0 = a0
self.b0 = b0
self.shape = shape
# def prec_div(self):
# return - tf.reduce_sum(gammaPrior(self.prec_a, self.prec_b, self.a0, self.b0))
## outputs E_q[ log N( x | 0, prec^-1) ] + Entropy(q(x))
## where x is the normally distributed variable
评论列表
文章目录