TExcelTAD
Home › Optimization › Proximal Operators

Proximal Operators

Many objectives split into a smooth part and a simple nonsmooth part: a loss plus an L1 penalty, a loss plus a constraint, a loss plus a nuclear norm. The proximal operator of the nonsmooth part is a small optimization problem, often with a closed-form solution, that plays the role a projection plays for constraints. Proximal gradient methods combine it with gradient steps and converge as fast as gradient descent on smooth problems.

Definition

The proximal operator of a convex function gg with parameter t>0t > 0 is

prox⁡tg(v)=arg⁡min⁡x(g(x)+12t∥x−v∥2)\operatorname{prox}_{tg}(\mathbf{v}) = \arg\min_{\mathbf{x}}\left(g(\mathbf{x}) + \frac{1}{2t}\lVert \mathbf{x} - \mathbf{v} \rVert^2\right)

It finds a point that makes gg small without moving far from v\mathbf{v}. Special cases:

gg prox⁡tg(v)\operatorname{prox}_{tg}(\mathbf{v})
00 v\mathbf{v} (no change)
indicator of a convex set CC (00 on CC, +∞+\infty outside) projection PC(v)P_C(\mathbf{v})
λ∥x∥1\lambda\lVert \mathbf{x} \rVert_1 soft threshold: sign⁡(vi)max⁡(∣vi∣−tλ,0)\operatorname{sign}(v_i)\max(\lvert v_i \rvert - t\lambda, 0)
λ2∥x∥22\frac{\lambda}{2}\lVert \mathbf{x} \rVert_2^2 v/(1+tλ)\mathbf{v}/(1 + t\lambda)
λ∥x∥2\lambda\lVert \mathbf{x} \rVert_2 (group lasso) vmax⁡(0,1−tλ/∥v∥2)\mathbf{v}\max(0, 1 - t\lambda/\lVert \mathbf{v} \rVert_2)
λ∥X∥∗\lambda\lVert X \rVert_* (nuclear norm) soft-threshold the singular values of VV
python · try it yourself
import numpy as np
from scipy.optimize import minimize_scalar

soft = lambda v, k: np.sign(v) * np.maximum(np.abs(v) - k, 0)
t, lam = 0.5, 2.0
for v in (-3.0, -0.4, 0.8, 2.5):
    brute = minimize_scalar(lambda x: lam * abs(x) + (x - v)**2 / (2 * t), bounds=(-10, 10), method="bounded", options={"xatol": 1e-10}).x
    print(f"v = {v:5.1f}: soft threshold {round(float(soft(v, t * lam)), 3) + 0.0:6.3f}, numerical prox {round(brute, 3) + 0.0:6.3f}")
v =  -3.0: soft threshold -2.000, numerical prox -2.000
v =  -0.4: soft threshold  0.000, numerical prox  0.000
v =   0.8: soft threshold  0.000, numerical prox  0.000
v =   2.5: soft threshold  1.500, numerical prox  1.500

Proximal gradient descent

To minimize F(x)=f(x)+g(x)F(\mathbf{x}) = f(\mathbf{x}) + g(\mathbf{x}) with ff smooth (LL-smooth) and gg simple:

xk+1=prox⁡tg(xk−t∇f(xk)),t≤1/L\mathbf{x}_{k+1} = \operatorname{prox}_{tg}\left(\mathbf{x}_k - t\nabla f(\mathbf{x}_k)\right), \qquad t \le 1/L

A gradient step on the smooth part, then a prox step on the rest. If gg is an indicator, this is projected gradient descent; if g=0g = 0, it is gradient descent. The convergence rate is O(1/k)O(1/k) for convex problems, linear under strong convexity, exactly as for gradient descent, even though FF is not differentiable.

Example: non-negative, sparse deconvolution

python · try it yourself
import numpy as np

rng = np.random.default_rng(0)
n = 60
x_true = np.zeros(n); x_true[[10, 25, 40]] = [3.0, 2.0, 4.0]          # a few spikes
kernel = np.exp(-0.5 * (np.arange(-6, 7) / 2.0)**2)
A = np.array([np.convolve(np.eye(n)[i], kernel, mode="same") for i in range(n)]).T
b = A @ x_true + 0.05 * rng.normal(size=n)
lam = 0.1; L = np.linalg.norm(A, 2)**2
x = np.zeros(n)
for k in range(3000):
    v = x - A.T @ (A @ x - b) / L
    x = np.maximum(v - lam / L, 0)          # prox of lam*|x|_1 + indicator(x >= 0): one-sided soft threshold
print("largest recovered spikes at:", np.sort(np.argsort(x)[-3:]), " heights:", np.round(np.sort(x)[-3:], 2))
print("non-zeros:", int(np.sum(x > 1e-6)), "of", n)
largest recovered spikes at: [10 25 40]  heights: [1.89 2.84 3.77]
non-zeros: 9 of 60

The three spikes are found at the right positions. The L1 penalty shrinks their heights a little (the usual lasso bias) and leaves a few small non-zeros next to them.

The Moreau envelope

The optimal value of the prox problem, Mtg(v)=min⁡x(g(x)+12t∥x−v∥2)M_{tg}(\mathbf{v}) = \min_{\mathbf{x}}\left(g(\mathbf{x}) + \frac{1}{2t}\lVert \mathbf{x} - \mathbf{v} \rVert^2\right), is a smooth approximation of gg with gradient (v−prox⁡tg(v))/t(\mathbf{v} - \operatorname{prox}_{tg}(\mathbf{v}))/t. For g=∣x∣g = \lvert x \rvert it is exactly the Huber function. Smoothing a nonsmooth function this way is another route to fast methods.

In software

  • scikit-learn's Lasso uses coordinate descent, but SGDClassifier(penalty="l1") and many sparse-coding and compressed-sensing codes use proximal steps; the proxsuite and pyproximal libraries collect proximal operators.
  • In deep learning, weight decay applied separately from the gradient update (AdamW) is a proximal step for λ2∥w∥2\frac{\lambda}{2}\lVert \mathbf{w} \rVert^2 (Adam and AdamW).

Exercises

Exercise 1: Prox of a quadratic

Derive prox⁡tg(v)\operatorname{prox}_{tg}(\mathbf{v}) for g(x)=λ2∥x∥2g(\mathbf{x}) = \frac{\lambda}{2}\lVert \mathbf{x} \rVert^2.

Answer

v/(1+tλ)\mathbf{v}/(1 + t\lambda).

Solution

Set the gradient of λ2∥x∥2+12t∥x−v∥2\frac{\lambda}{2}\lVert \mathbf{x} \rVert^2 + \frac{1}{2t}\lVert \mathbf{x} - \mathbf{v} \rVert^2 to zero: λx+(x−v)/t=0\lambda\mathbf{x} + (\mathbf{x} - \mathbf{v})/t = 0.

Exercise 2: Prox of an indicator

Why is the prox of the indicator of a set CC the projection onto CC?

Answer

The indicator is 0 on CC and +∞+\infty outside, so the problem is min⁡x∈C12t∥x−v∥2\min_{\mathbf{x} \in C}\frac{1}{2t}\lVert \mathbf{x} - \mathbf{v} \rVert^2.

Solution

Points outside CC have infinite cost, and on CC only the distance term remains; its minimizer is the closest point of CC, independent of tt.

Exercise 3: Group soft threshold (code)

Compute the prox of λ∥x∥2\lambda\lVert \mathbf{x} \rVert_2 with tλ=1t\lambda = 1 at v=(3,4)\mathbf{v} = (3, 4) and at v=(0.3,0.4)\mathbf{v} = (0.3, 0.4).

Answer

(2.4,3.2)(2.4, 3.2) and (0,0)(0, 0).

Solution
python · try it yourself
import numpy as np
prox = lambda v, k: v * max(0.0, 1 - k / np.linalg.norm(v))
print(prox(np.array([3.0, 4.0]), 1.0), prox(np.array([0.3, 0.4]), 1.0))
[2.4 3.2] [0. 0.]

The vector is shortened by 1 in length; if it is shorter than 1, the whole group is set to zero, which is how the group lasso removes entire groups of features.

Test yourself

The proximal operator of λ∥x∥1\lambda\lVert \mathbf{x} \rVert_1 is…

  1. a projection onto the simplex
  2. soft thresholding
  3. hard thresholding
  4. the identity

Proximal gradient descent with gg = indicator of a convex set is…

  1. Newton's method
  2. projected gradient descent
  3. coordinate descent
  4. the simplex method

For convex f+gf + g with LL-smooth ff, proximal gradient converges at rate…

  1. O(1/k)O(1/k), like gradient descent
  2. O(1/k)O(1/\sqrt{k}), like subgradients
  3. it does not converge
  4. quadratically