Skip to content
DeepForgeby svx
All problems

Evolution Strategies Gradient Estimate

Problem

Estimate the evolution strategies gradient from sampled perturbations: (1 / (n * sigma)) * sum of fitness[i] * epsilon[i], returned as a vector. An empty batch returns [].

Hint

The score-function trick turns black-box fitness into a gradient estimate.

Test cases

case 1
in: [[1,-1],[[1,0],[1,0]],1]
expected: [0,0]
case 2
in: [[2,4],[[1,-1],[0,1]],0.5]
expected: [2,2]
case 3
in: [[1,2,3],[[1,0],[0,1],[-1,-1]],2]
expected: [-0.3333333333333333,-0.16666666666666666]
Starter codePython
def es_gradient_estimate(fitness, epsilons, sigma):
    # Your code here
    pass

3 test cases · run your code against them in the editor