All problems
Proximal Gradient L1 Step
Problem
One proximal gradient step for an L1-penalized objective evaluates z = w - lr * grad, then applies the soft threshold with parameter lr * lambda.
Given w, grad, lr, and lambda, return the updated vector.
Hint
Soft threshold each coordinate after the gradient step.
Test cases
case 1
in: [[1,2],[0.5,-0.5],0.1,0.5]
expected: [0.8999999999999999,1.9999999999999998]
case 2
in: [[0,0],[1,1],1,0.5]
expected: [-0.5,-0.5]
case 3
in: [[3,-3],[0,0],0.1,0.5]
expected: [2.95,-2.95]
Starter codePython
def proximal_gradient_l1_step(w, grad, lr, lam):
# Your code here
pass3 test cases · run your code against them in the editor