Reparameterize a Gaussian
~8 mincode completion
Implement reparameterize(mu, sigma, eps) returning z of the same shape as mu.
Examples
eps=0 returns mu
- Input
- reparameterize([1, 2], [0.5, 1], [0, 0])
- Output
- [1, 2]
sigma=1, eps=(0, 1) shifts the second coordinate by 1
- Input
- reparameterize([1, 2], [0.5, 1], [0, 1])
- Output
- [1, 3]
Hints
Hint 1
Convert the input with before doing elementwise work.
Hint 2
Watch for this: added eps without scaling by sigma.
Requirements
Return array, same shape as mu
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~8 min
••••••••••••••••
8 employers weight this skill
4 autonomy companies, 1 enterprise vendor, 1 defense company, 1 health and bio company, 1 AI product company. Top match scores 87.
Python
import numpy as np
def reparameterize(mu, sigma, eps):
"""
z = mu + sigma * eps, elementwise.
Args:
mu, sigma, eps: arrays of the same shape
Returns:
array, same shape as mu
"""
# YOUR CODE HERE
pass