Proximal methods
近端方法
Handle nonsmooth penalties through a proximal operator, with exact soft-thresholded steps.
proximal-methodsA corner does not have to be rounded away
An absolute-value penalty encourages small coefficients to become exactly zero. Its corner at zero is useful, but an ordinary derivative is not defined there. Replacing the corner by a smooth approximation changes the objective. Proximal methods offer another route: handle that part through a small minimization problem that can often be solved exactly.
In our example, a smooth coupled quadratic is combined with an L1 penalty. A gradient step handles the quadratic; soft thresholding handles the penalty. One coordinate becomes exactly zero after several iterations while the other continues toward its optimum.
Read convexity, Lasso and gradient descent first. The main guarantee here concerns convex functions; “proximal” is not a blanket guarantee for arbitrary nonconvex penalties.
Balance the penalty against distance from a proposed point
For a proper closed convex function r, which may take the value +∞ to encode constraints, and t>0, define:
Here “proper” means r never equals −∞ and is finite somewhere. “Closed” means its epigraph—the set of points on or above its graph—is closed under limits. In finite-dimensional Euclidean space this problem has a unique minimizer. The squared-distance term keeps the answer near v and makes the objective strongly convex. This does not mean the proximal operator is always cheap to compute. The Parikh–Boyd author manuscript, §1.1 defines the operator and its basic interpretation.
For r(z)=λ|z| with λ≥0, solve separately on positive z, negative z and the corner at zero. The result is soft thresholding:
Positive surviving values decrease by tλ, negative ones increase by tλ, and values within the threshold become zero. At zero, the absolute-value subgradient is the interval [−1,1]; it can balance a small v without requiring a nonzero output. The same piecewise operation appears as Softshrink in the fixed PyTorch 2.8 documentation. This chapter implements it with fractions and does not run PyTorch.
Linearize only the smooth part
To minimize F(x)=f(x)+r(x), where f is convex with an L-Lipschitz gradient, use:
This step minimizes r plus a quadratic upper model of f. The upper model agrees with f at the current point, so exact minimization cannot increase the composite objective for this step range. Under the standard convex assumptions and existence of a minimizer, the basic method has an O(1/k) objective-gap guarantee for a fixed step in this range. That bound is not a claim that every problem attains only that rate. The manuscript’s §4.2 explains the model and assumptions.
A proximal-point step instead applies the proximal operator to the entire objective without linearizing f. If r is the indicator of a nonempty closed convex set C—zero on C and +∞ elsewhere—its proximal operator is Euclidean projection onto C. Thus projected gradient is a special case of proximal gradient.
A sparse optimum with a hand-checkable certificate
Our composite objective is:
The smooth Hessian is [[2,1],[1,2]], with eigenvalues 1 and 3, so L=3 and t=1/3 is valid. Thresholding uses tλ=1/6, not λ=1/2 alone. The exact optimum is (3/4,0), with value −9/16. At that point the smooth gradient is (−1/2,−1/4). An L1 subgradient contribution of (1/2,1/4) cancels it: the zero second coordinate permits any contribution between −1/2 and 1/2. Convexity makes this a global certificate, and the strictly convex quadratic makes the solution unique.
Take exact proximal-gradient steps
Run the complete Python 3.12 standard-library program. It accepts rational values, rejects negative thresholds, and restricts the example’s step to (0,1/3]. Both gradient components read the same old point before the new pair is returned. This is a full proximal-gradient step, not the sequential coordinate sweep from coordinate descent.
from fractions import Fraction as F
def rational(value):
if type(value) not in (int,F):
raise ValueError('integer or Fraction required')
return F(value)
def soft(value,threshold):
value,threshold=map(rational,(value,threshold))
if threshold < 0:
raise ValueError('threshold must be nonnegative')
return max(value-threshold,F(0))-max(-value-threshold,F(0))
def objective(x):
a,b=x
return a*a+a*b+b*b-2*a-b+(abs(a)+abs(b))/2
def update(x,step=F(1,3)):
if type(x) not in (list,tuple) or len(x) != 2:
raise ValueError('two coordinates required')
a,b=map(rational,x);step=rational(step)
if not 0 < step <= F(1,3):
raise ValueError('demonstration uses step in (0,1/3]')
return (soft(a-step*(2*a+b-2),step/2),
soft(b-step*(a+2*b-1),step/2))
if __name__ == '__main__':
x=(F(0),F(0))
for k in range(7):
print('step='+str(k),'x='+str([str(v) for v in x]),
'objective='+str(objective(x)))
if k < 6:
new=update(x)
assert objective(new) <= objective(x)
x=new
optimum=(F(3,4),F(0))
assert update(optimum)==optimum
assert objective(optimum)==F(-9,16)
print('exact optimum:',[str(v) for v in optimum], 'objective=-9/16')
Output:
step=0 x=['0', '0'] objective=0
step=1 x=['1/2', '1/6'] objective=-17/36
step=2 x=['11/18', '1/18'] objective=-173/324
step=3 x=['37/54', '0'] objective=-407/729
step=4 x=['59/81', '0'] objective=-7375/13122
step=5 x=['361/486', '0'] objective=-33212/59049
step=6 x=['545/729', '0'] objective=-597865/1062882
exact optimum: ['3/4', '0'] objective=-9/16
The first iterate is (1/2,1/6). The second coordinate becomes zero on the third update. Six iterations still need not equal the exact optimum; the program separately supplies and verifies the analytic optimum. The objective checks use exact fractions, so zeros and monotonicity here are not artifacts of a floating-point threshold tolerance.
For a dense quadratic in d coordinates, its matrix-vector gradient costs O(d²) arithmetic, while elementwise L1 thresholding costs O(d). Other smooth objectives and penalties have different costs. The two-coordinate example uses constant work per step; Fraction bit sizes grow during iteration.
Know which operator your penalty requires
Soft thresholding is the proximal operator of a scaled L1 norm, not of every sparsity penalty. Hard thresholding corresponds to different nonconvex formulations. Projection onto an L1 ball also uses a threshold, but that threshold must be chosen to satisfy the ball constraint; it is not automatically the penalty parameter λ.
For a coupled regularizer such as total variation, the proximal operation can itself require an iterative solver. An inaccurate inner solve changes the convergence analysis. Acceleration and larger step sizes also need their own conditions; do not assume the simple monotone upper-model argument applies unchanged.
This example uses a convex regularizer, a known gradient Lipschitz constant and exact proximal calculations. It does not prove a method converges for an arbitrary neural-network loss. Parameter scaling also matters: changing a loss normalization while keeping λ fixed changes the tradeoff, not just the speed.
Keep the step and the threshold separate
- If λ=1/2 and t=1/3, what threshold should the proximal-gradient step use?
Answer 1: tλ=1/6. Using 1/2 would implement a different step/regularization scaling.
- Apply soft thresholding with threshold 1 to values −2, −1/2, 0, 1/2 and 2.
Answer 2: The results are −1,0,0,0,1. Small values become zero and larger magnitudes shrink toward zero.
- Why can the optimum have y=0 even though the smooth y derivative there is −1/4?
Answer 3: The nonsmooth penalty supplies a subgradient contribution +1/4 at zero, within the allowed interval [−1/2,1/2], so the composite optimality condition is satisfied.
- If r is a closed convex set’s indicator, what does the proximal-gradient step become?
Answer 4: Take a gradient step for the smooth objective, then project onto the set. The indicator forbids outputs outside the set; the distance term chooses the closest permitted point.
Choose a split whose nonsmooth part can be solved
Parikh and Boyd organize proximal operators, their calculus and algorithmic uses. The inspected author PDF has a 2013 draft cover; that version label is not a claim about the final journal publication date. PyTorch’s fixed documentation provides a familiar implementation name for soft thresholding without supplying our optimization proof.
Continue with constrained optimization to use projection as an operator. For a project, change the L1 penalty strength, derive the corresponding optimality conditions, and check when each coordinate becomes zero. Compare algorithms only after fixing the same composite objective.
Make a prediction, then check
With step t and penalty λ||x||₁, which soft threshold belongs in proximal gradient?
Learning objectives
- Derive soft thresholding from a scalar proximal problem.
- Choose the threshold tλ and verify a sparse optimum.
Prerequisites & connections
Explore related knowledge →References
- Proximal Algorithms — author PDF with 2013 draft cover
Neal Parikh; Stephen Boyd · 2013 - Softshrink — PyTorch 2.8 documentation
PyTorch developers
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-06 · Codex single-agent authored technical review: primary-source locations, explicit assumptions, derivations, literal or exact computational checks, and bilingual review; not independent human or second-agent peer review.
- Single-agent authored technical review: source locations, stated domains and assumptions, derivations, literal or exact reference cases and matching bilingual programs/exercises. Not independent human or second-agent peer review.
- Four focused tests passed on CPython 3.12.4. Exact Fraction examples are used except for the explicitly floating-point damped Newton experiment. Strict bilingual MDX/KaTeX rendering gives four equations, six anchors and four answers per language; repository publication checks are recorded separately.
- Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
- Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.
Source locations checked:
- Proximal Algorithms — author PDF with 2013 draft cover · Author PDF cover prints 2013 draft and placeholder DOI; §1.1 definition, §4.2 gradient splitting/step bound, §6.5 soft thresholding.
- Softshrink — PyTorch 2.8 documentation · Fixed 2.8 Softshrink class: piecewise formula and nonnegative lambd parameter. Documentation read only; no PyTorch execution claimed.
Related topics