All problems
Reparameterization Gradient
Problem
With the reparameterization z = mu + sigma * eps, the pathwise derivatives of f(z) are df/dmu = f'(z) and df/dsigma = f'(z) * eps.
For f(x) = sum(coeffs[i] * x^i), evaluate f'(z) and return [df_dmu, df_dsigma].
Hint
The same derivative value scales the sigma partial by the noise sample.
Test cases
case 1
in: [[0,0,1],1,2,0.5]
expected: [4,2]
case 2
in: [[0,0,0,1],0,1,-2]
expected: [12,-24]
case 3
in: [[0,1],0,3,1]
expected: [1,1]
case 4
in: [[5],1,1,1]
expected: [0,0]
Starter codePython
def reparameterization_grad(coeffs, mu, sigma, eps):
# Return [df_dmu, df_dsigma]
# Your code here
pass4 test cases · run your code against them in the editor