Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-267

Hedge Update Weights

Problem

Perform one multiplicative-weights (Hedge) update and return the new normalized expert weights:

w_new[i] proportional to w[i] * exp(-eta * loss[i])

Hint

Experts that suffer larger losses lose weight exponentially fast.

Test cases

case 1
in: [[0.5,0.5],[1,0],0.5]
expected: [0.37754066879814546,0.6224593312018546]
case 2
in: [[1,1],[0,0],1]
expected: [0.5,0.5]
case 3
in: [[0.5,0.5],[0,1],2]
expected: [0.8807970779778823,0.11920292202211755]
case 4
in: [[0.25,0.75],[1,1],1]
expected: [0.25,0.75]
Starter codePython
import math
def hedge_update_weights(weights, losses, eta):
    # Your code here
    pass

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