All problems
Gradient Variance Estimate
Problem
Estimate the mean and variance of a batch of scalar gradient samples.
Return [mean, population_variance] using division by n. An empty batch returns [0.0, 0.0].
Hint
This estimates how noisy the policy-gradient estimator is.
Test cases
case 1
in: [[1,3]]
expected: [2,1]
case 2
in: [[2,2,2]]
expected: [2,0]
case 3
in: [[-1,0,1]]
expected: [0,0.6666666666666666]
case 4
in: [[]]
expected: [0,0]
Starter codePython
def gradient_variance(grads):
# Your code here
pass4 test cases · run your code against them in the editor