All problems
VAE Reparameterization (Seeded)
Problem
Sample a latent vector with the reparameterization trick: z_i = mu_i + exp(0.5 * log_var_i) * eps_i, where each eps_i is drawn from a standard normal. Call random.seed(seed) first and draw eps with random.gauss(0.0, 1.0) in order.
The signature is vae_reparameterize(mu, log_var, seed).
Hint
Sampling eps outside the network keeps the path differentiable with respect to mu and log_var.
Test cases
case 1
in: [[0,0],[0,0],0]
expected: [0.9417154047,-1.3965781047]
case 2
in: [[1],[0],42]
expected: [0.8559096704]
case 3
in: [[0],[0],7]
expected: [-0.2558802884]
case 4
in: [[2,-1],[1,0],123]
expected: [2.6664600161,-0.8619886074]
Starter codePython
import math
import random
def vae_reparameterize(mu, log_var, seed):
# Your code here
pass4 test cases · run your code against them in the editor