def encode(self, h_enc, batch_size):
     z_mu = self.z_mu(h_enc)
     z_logvar = self.z_logvar(h_enc)
     z_eps = self.samples(batch_size)
     z = z_mu + ex.exp(0.5 * z_logvar) * z_eps
     kld = KLDStandardNormal()(z_mu, z_logvar)
     return z, kld
 def encode(self, h_enc, batch_size):
     z_mu = self.z_mu(h_enc)
     z_logvar = self.z_logvar(h_enc)
     z_eps = self.samples(batch_size)
     z = z_mu + ex.exp(0.5 * z_logvar) * z_eps
     kld = KLDStandardNormal()(z_mu, z_logvar)
     return z, kld
 def encode(self, h_enc, batch_size, phase=None):
     z_mu = self.z_mu(h_enc)
     z_log_sigma = self.z_log_sigma(h_enc)
     if phase is None:
         phase = self.phase
     if phase == 'test':
         z = z_mu
     else:
         z_eps = self.samples(batch_size)
         z = z_mu + expr.exp(0.5 * z_log_sigma) * z_eps
     kld = KLDivergence()(z_mu, z_log_sigma)
     return z, kld
Esempio n. 4
0
 def __call__(self, h_enc):
     z_mu = self.z_mu(h_enc)
     z_log_sigma = self.z_log_sigma(h_enc)
     eps = expr.random.normal(size=(self.batch_size, self.n_hidden))
     z = z_mu + expr.exp(0.5 * z_log_sigma) * eps
     return z, z_mu, z_log_sigma
 def __call__(self, h_enc):
     z_mu = self.z_mu(h_enc)
     z_log_sigma = self.z_log_sigma(h_enc)
     eps = expr.random.normal(size=(self.batch_size, self.n_hidden))
     z = z_mu + expr.exp(0.5 * z_log_sigma) * eps
     return z, z_mu, z_log_sigma