Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-065

EMA of Weights

Problem

Update an exponential moving average of the weights: ema_new = decay * ema + (1 - decay) * new_weights.

The signature is ema_update(ema_weights, new_weights, decay).

Hint

A decay near 1 keeps the old average while slowly tracking new weights.

Test cases

case 1
in: [[1,2],[3,4],0.9]
expected: [1.2,2.2]
case 2
in: [[0],[1],0.5]
expected: [0.5]
case 3
in: [[1,1],[0,0],0.25]
expected: [0.25,0.25]
case 4
in: [[0,0],[1,1],1]
expected: [0,0]
Starter codePython
def ema_update(ema_weights, new_weights, decay):
    # Your code here
    pass

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