All problems
L-BFGS Memory Scaling
Problem
Compute the L-BFGS initial Hessian scaling from the newest correction pair.
Return (s dot y) / (y dot y), the gamma that multiplies the identity before the two-loop recursion. If y is the zero vector, return 1.0.
Hint
This scalar keeps the scaled identity consistent with the local curvature.
Test cases
case 1
in: [[1,2],[2,4]]
expected: 0.5
case 2
in: [[1,1],[1,-1]]
expected: 0
case 3
in: [[0.5],[0]]
expected: 1
case 4
in: [[-1,2],[0.5,1.5]]
expected: 1
Starter codePython
def lbfgs_memory_scaling(s, y):
# Your code here
pass4 test cases · run your code against them in the editor