All problems
Lookahead Multi-Step Averaging
Problem
Apply several Lookahead interpolations to a slow weight vector.
Starting from slow, process each fast vector in fast_history in order with slow = slow + alpha * (fast - slow). Return [slow_final, fast_final] where fast_final is a copy of the final slow weights. An empty history returns the starting weights unchanged.
Hint
Each interpolation moves the slow weights a fraction alpha toward the observed fast weights.
Test cases
case 1
in: [[0,0],[[2,4],[3,1]],0.5]
expected: [[2,1.5],[2,1.5]]
case 2
in: [[1,1],[[1,1]],0.9]
expected: [[1,1],[1,1]]
case 3
in: [[0],[[10],[0],[10]],0.25]
expected: [[3.90625],[3.90625]]
Starter codePython
def lookahead_multistep(slow, fast_history, alpha):
# Returns [slow_final, fast_final]
# Your code here
pass3 test cases · run your code against them in the editor