Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-292

Prototype Memory Update

Problem

Update a class prototype with an exponential moving average of a new feature.

Return round(momentum * prototype[k] + (1 - momentum) * feature[k], 4) for every dimension.

Test cases

case 1
in: [[1,0],[0.5,0.5],0.9]
expected: [0.95,0.05]
case 2
in: [[0,0],[1,1],0]
expected: [1,1]
case 3
in: [[1,1],[0,0],1]
expected: [1,1]
Starter codePython
def update_prototype(prototype, feature, momentum):
    # Your code here
    pass

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