Skip to content

Instantly share code, notes, and snippets.

@ericjang
Created February 24, 2016 16:45
Show Gist options
  • Save ericjang/72055c383fc047e07039 to your computer and use it in GitHub Desktop.
Save ericjang/72055c383fc047e07039 to your computer and use it in GitHub Desktop.
def sampleQ(h_enc):
"""
Samples Zt ~ normrnd(mu,sigma) via reparameterization trick for normal dist
mu is (batch,z_size)
"""
with tf.variable_scope("mu",reuse=DO_SHARE):
mu=linear(h_enc,z_size)
with tf.variable_scope("sigma",reuse=DO_SHARE):
logsigma=linear(h_enc,z_size)
sigma=tf.exp(logsigma)
return (mu + sigma*e, mu, logsigma, sigma)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment