All problems
Model Averaging Weights
Problem
Compute softmax model averaging weights from losses: exp(-(loss_i - min_loss)/T) normalized to sum to 1.
Return uniform weights when temperature <= 0 and [] for empty input.
Hint
Lower temperature concentrates weight on the best-performing model.
Test cases
case 1
in: [[0.1,0.5],0.2]
expected: [0.8807970779778823,0.11920292202211755]
case 2
in: [[1,1],0.2]
expected: [0.5,0.5]
case 3
in: [[0.5],0]
expected: [1]
case 4
in: [[],1]
expected: []
Starter codePython
import math
def model_averaging_weights(losses, temperature):
# Your code here
pass4 test cases · run your code against them in the editor