Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-028

EMA Weights Update

Problem

Update exponential moving average weights elementwise.

For each coordinate return decay * ema_old + (1 - decay) * params. The two lists must be traversed in parallel.

Hint

Higher decay keeps more of the old EMA.

Test cases

case 1
in: [[1,1],[2,0],0.9]
expected: [1.1,0.9]
case 2
in: [[0,0,0],[1,-1,2],0.5]
expected: [0.5,-0.5,1]
case 3
in: [[5],[1],0]
expected: [1]
Starter codePython
def ema_update(ema, params, decay):
    # Your code here
    pass

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