in model.py [0:0]
def prior(name, y_onehot, hps):
with tf.variable_scope(name):
n_z = hps.top_shape[-1]
h = tf.zeros([tf.shape(y_onehot)[0]]+hps.top_shape[:2]+[2*n_z])
if hps.learntop:
h = Z.conv2d_zeros('p', h, 2*n_z)
if hps.ycond:
h += tf.reshape(Z.linear_zeros("y_emb", y_onehot,
2*n_z), [-1, 1, 1, 2 * n_z])
pz = Z.gaussian_diag(h[:, :, :, :n_z], h[:, :, :, n_z:])
def logp(z1):
objective = pz.logp(z1)
return objective
def sample(eps=None, eps_std=None):
if eps is not None:
# Already sampled eps. Don't use eps_std
z = pz.sample2(eps)
elif eps_std is not None:
# Sample with given eps_std
z = pz.sample2(pz.eps * tf.reshape(eps_std, [-1, 1, 1, 1]))
else:
# Sample normally
z = pz.sample
return z
def eps(z1):
return pz.get_eps(z1)
return logp, sample, eps