All problems
Armijo Backtracking Halving Count
Problem
Along a direction with initial local model f(lr) = f0 + slope * lr + 0.5 * curvature * lr^2, backtracking halves the step until f(lr) <= f0 + c * slope * lr (Armijo).
Given f0, slope (negative), curvature, initial lr, the halving factor rho, and c, return [halvings, final_lr, final_f].
Hint
Evaluate the quadratic model at the trial step before every shrink.
Test cases
case 1
in: [1,-2,1,1,0.5,0.1]
expected: [0,1,-0.5]
case 2
in: [5,-1,10,2,0.5,0.5]
expected: [5,0.0625,4.95703125]
case 3
in: [0,-4,0,1,0.5,0.25]
expected: [0,1,-4]
Starter codePython
def armijo_backtracking_halving_count(f0, slope, curvature, lr, rho, c):
# Your code here
pass3 test cases · run your code against them in the editor