MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / sampling

Function sampling

One_Day_One_GAN/day15/model.py:15–26  ·  view source on GitHub ↗

Reparameterization trick by sampling from an isotropic unit Gaussian. # Arguments: args (tensor): mean and log of variance of Q(z|X) # Returns: z (tensor): sampled latent vector

(args)

Source from the content-addressed store, hash-verified

13latent_dim = 6
14
15def sampling(args):
16 """Reparameterization trick by sampling from an isotropic unit Gaussian.
17 # Arguments:
18 args (tensor): mean and log of variance of Q(z|X)
19 # Returns:
20 z (tensor): sampled latent vector
21 """
22 z_mean, z_log_var = args
23 batch = K.shape(z_mean)[0]
24 dim = K.int_shape(z_mean)[1]
25 epsilon = K.random_normal(shape=(batch, dim))
26 return z_mean + K.exp(0.5 * z_log_var) * epsilon
27
28def build_model():
29 """Builds/compiles the model and returns (encoder, decoder, vae)."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected