All problems
Proximal Gradient Step 1D
Problem
Perform one proximal gradient step with a squared L2 regularizer.
Compute z = w - lr * grad, then apply the proximal operator of (lam / 2) * ||w||^2, which is z / (1 + 2 * lr * lam). Return the new value.
Hint
The squared L2 prox divides by 1 + 2 * lr * lam.
Test cases
case 1
in: [1,0.5,0.1,0.2]
expected: 0.9134615384615384
case 2
in: [2,-1,0.5,0.1]
expected: 2.2727272727272725
case 3
in: [0,0,0.3,1]
expected: 0
case 4
in: [-1,2,0.2,0]
expected: -1.4
Starter codePython
def proximal_gradient_step(w, grad, lr, lam):
# Your code here
pass4 test cases · run your code against them in the editor