Proximal gradient methods
Define the proximal operator and use proximal gradient descent for nonsmooth objectives like the L1 penalty.
Gradient descent needs a gradient, but the most useful regularizer, the L1 penalty that produces sparsity, is not differentiable at zero. Proximal methods split the objective into a smooth part and a simple nonsmooth part, taking a gradient step on the first and a proximal step on the second. For the L1 penalty the proximal step is soft-thresholding, and the result is the LASSO solver ISTA.
The composite problem
Many learning objectives have the form
where is convex and -smooth (a data-fit loss) and is convex but possibly nondifferentiable (a regularizer like ). Plain gradient descent fails on ; the proximal operator handles it exactly.
The proximal operator
The proximal operator of a function with step is
[1]It returns the point that balances minimizing against staying near . It generalizes projection: if is the indicator of a convex set (zero inside, outside), the prox is exactly Euclidean projection onto that set.
Proximal gradient descent
Proximal gradient descent alternates a gradient step on with a prox step on :
The motivation mirrors the gradient-descent derivation: model by its linearization plus a proximity penalty, keep exact, and minimize. The minimizer of is precisely the prox of applied to the gradient step. With it converges at the same rate as smooth gradient descent, and an accelerated version (FISTA, Nesterov momentum on top) reaches [2].
Soft-thresholding for the L1 penalty
For the prox decouples across coordinates, and each solves . The solution is the soft-thresholding operator:
It shrinks every coordinate toward zero by and sets to exactly zero anything smaller than the threshold. This is where L1's sparsity comes from mechanically: the prox step zeroes out small coordinates each iteration. Proximal gradient descent with this prox is ISTA, the iterative soft-thresholding algorithm for LASSO.
Watching the operator act on a few coordinates makes the two behaviors concrete. With threshold :
- A large coordinate survives but is pulled in: .
- A mid coordinate takes the same fixed cut, dropping to . The shrinkage is the same absolute amount, so it bites hardest in relative terms here.
- A small coordinate falls below the threshold and is set to .
- The sign carries through unchanged: maps to , and maps to .
Contrast this with the gradient step on a smooth L2 penalty, which would scale every coordinate by a factor like : the small would become , still nonzero. Soft-thresholding subtracts a constant instead of scaling, and that constant is what pushes small coordinates to exact zero rather than merely shrinking them.
Check it on arrays
import numpy as np
rng = np.random.default_rng(0)
# Sparse recovery: y = A x_true + noise, x_true mostly zero (n < d, underdetermined).
n, d, k = 150, 200, 8
A = rng.normal(size=(n, d)) / np.sqrt(n)
x_true = np.zeros(d)
x_true[rng.choice(d, k, replace=False)] = rng.normal(size=k) * 3
y = A @ x_true + 0.01 * rng.normal(size=n)
def soft_threshold(v, t):
return np.sign(v) * np.maximum(np.abs(v) - t, 0.0)
L = np.linalg.eigvalsh(A.T @ A).max() # smoothness of 0.5||Ax-y||^2
eta = 1.0 / L
lam = 0.1
x = np.zeros(d)
for _ in range(1500):
grad = A.T @ (A @ x - y) # gradient of the smooth part
x = soft_threshold(x - eta * grad, eta * lam) # prox step
print("recovered nonzeros:", int(np.sum(np.abs(x) > 1e-2)), " true:", k)
print("support match:", np.array_equal(np.abs(x) > 1e-2, x_true != 0))
print("reconstruction error:", round(np.linalg.norm(x - x_true), 4))ISTA recovers the correct sparse support through repeated soft-thresholding, with small coordinates driven to exact zero.
Exercises
Exercise 1. Apply soft-thresholding with threshold to the vector by hand, coordinate by coordinate.
Solution
Step 1. The operator is . Apply it to each entry.
Step 2. Work through the coordinates:
The result is . Every surviving coordinate is pulled toward zero by the same , and the two coordinates below the threshold become exactly zero.
Exercise 2. Derive soft-thresholding from the proximal definition. For one coordinate, minimize over and recover the formula. Treat the cases , , and separately, since is nondifferentiable at zero.
Solution
Step 1. Where , is smooth and gives . This is a valid (positive) solution only when .
Step 2. Where , and gives , valid (negative) only when .
Step 3. For neither branch is feasible, so the minimizer sits at the kink . The optimality condition there uses the subgradient :
This holds exactly when , confirming on that interval.
Step 4. Stitch the three cases together:
the soft-thresholding operator.
Exercise 3 (code). The prox of the indicator of a convex set is Euclidean projection onto that set. Take the box , whose prox is clamping. Implement the projection and verify the defining property of a projection: the projected point is the closest point of to , so for any other , .
Solution
import numpy as np
rng = np.random.default_rng(0)
def project_box(v):
return np.clip(v, -1.0, 1.0) # prox of indicator of [-1,1]^d
d = 6
for _ in range(2000):
v = rng.normal(size=d) * 2.0 # often outside the box
p = project_box(v)
# any other point u inside the box is no closer to v than p is
u = rng.uniform(-1.0, 1.0, size=d)
assert np.linalg.norm(v - p) <= np.linalg.norm(v - u) + 1e-12
# Projection is idempotent: projecting an in-box point returns it unchanged.
inside = rng.uniform(-1.0, 1.0, size=d)
assert np.allclose(project_box(inside), inside)
print("box projection verified for d =", d)Clamping returns the nearest box point: each coordinate is moved the least possible amount to satisfy . The inequality confirms it is a genuine Euclidean projection, the prox of the box indicator.
The final A3 lesson optimizes functions with no gradient at all, using a probabilistic surrogate: Bayesian optimization.
References
- [1]Parikh, N., & Boyd, S. (2014). "Proximal algorithms". Foundations and Trends in Optimization, 1(3), 127-239. The proximal operator and proximal gradient method (doi:10.1561/2400000003).↩
- [2]Beck, A., & Teboulle, M. (2009). "A fast iterative shrinkage-thresholding algorithm for linear inverse problems". SIAM Journal on Imaging Sciences, 2(1), 183-202. ISTA, soft-thresholding, and the accelerated FISTA rate (doi:10.1137/080716542).↩