For finding local minima of differentiable functions, the work-horse algorithm of
machine learning is gradient descent.
Gradient descent is really a special case of a wider family of non-linear
optimization algorithms, and recognizing this fact allows us to address
constraints, consider alternative metrics, and be more explicit about the
approximations we use and the sequence of subproblems we solve.
The most basic form of gradient descent, where we seek to minimize an objective
function
f:X→R over decision variable
x∈X, is
xt+1=xt−η∇f(xt),(1)
where
η>0 is some step-size that we must choose.
This equation is the solution that minimizes a local approximation of
f
plus a regularization term
D that penalizes us for choosing
x that
results in large updates. That is, gradient descent generates a sequence of
candidate solutions
xt by solving a sequence of subproblems of the form
Exercise: Prove this by solving
∇(f^t(x)+Dt(x))=0.
There are a number of generalizations of Eq. (2) beyond
Eq. (3). For example,
We may choose non-Euclidean update metrics
Dt.
We may choose
Dt based on multiple past iterates.
We may choose surrogate estimates
f^t.
We may replace
f with a Lagrangian to address constraints.
In the following sections, I give examples of each of these generalizations.
Pseudo-Riemannian Geometry
Let us consider linear approximations of the form
f^t(x)=f(xt)+⟨∇f(xt),x−xt⟩,(4)
and distances
Dt of the form
Dt(x)=21(x−xt)⊤Gt(x−xt),(5)
where
Gt is a (pseudo)metric on the tangent space of
x.
Under these conditions, it follows that
xt+1=xt−Gt†∇f(xt),(6)
where
Gt† is the
Moore-Penrose
(pseudo)inverse of
Gt. This update rule is commonly known as
“preconditioned” gradient descent.
Importantly, these conditions correspond to the limit of updates in
continuous-time for the true objective
f and any
Dt with
positive-semidefinite Hessian, wherein
∇[f(x)+D˙t(x)](x=xt)=0
(Amid and Warmuth (2020)) (which may be understood as an instance of Lagrange multipliers to solve a constrained optimization problem). To see this,
let
Gt=∂x2∂2Dt(x)⟹∇D˙t(x)=x˙∂x2∂2Dt(x)=Gtx˙.
It follows that
x˙t=−Gt†∇f(xt).
Note that we use the dot (e.g., over
xt and
Dt) to represent a
time-derivative.
Gauss-Newton
If our objective function
f is convex, we are guaranteed that the Hessian
of
f, which we denote as
H, is positive semi-definite. That is,
Ht=∂x2∂2f(xt)⪰0.
When we substitute
Ht for
Gt in Eq. (5) (i.e., when we
choose
Dt based on the Hessian of
f), then the resulting subproblem
(Eq. (2)) is simply a minimization over a 2nd-order Taylor
approximation of
f at
xt. The resulting update is known as Newton’s
Method.
When used for solving least-squares problems (for residuals
ri(x)), the
Hessian may be calculated as
Ignoring the second term on the last line and retaining only the first as an
approximation for
Ht yields the Gauss-Newton algorithm. For linear
models, the second term is identically zero.
Fisher-Rao
We may also choose values of
G that derive from spaces other than
X. For example, when
x parameterizes a probability
distributionρ(y;x), from which the objective function
f derives,
we may measure the magnitude of an update from
xt to
x by the
relative entropy from
ρt to
ρ.
This choice yields the update rule for Fisher-Rao natural gradient descent:
xt+1=xt−ηFt†∇f(xt),(7)
where
Ft is the Fisher metric tensor
Ft=∫Yρ(y;xt)∂x2∂2logρ(y;x)dy.
One way to understand the effect of the metric
G=F is that it (un)warps
the space of marginal updates
dx, such that updates of the same
induced magnitude contain the same amount of marginal information about
ρ(xt+dx).
In continuous time, Fisher-Rao natural gradient descent optimally approximates
replicator dynamics (used to model evolution by natural selection) and
continuous Bayesian inference (Raab et. al.
(2022)). We may also choose different divergences in
ρ space, yielding
other forms of “natural gradient descent”
(Nurbekyan et. al. (2022)).
Projective Geometry
Vanilla gradient descent does not require a Euclidean metric.
As a counterexample, let
G=∇⊤f⋅∇f∇f∇⊤f,
where the numerator is an outer product and the denominator an inner product of
∇f with itself.
It follows that
G†=GandG†∇f=∇f.
Therefore, the update rule that solves
∇(f^t+Dt)=0
(Eq. (2)) is vanilla gradient descent:
xt+1−xt=−ηG†∇f(xt)=−η∇f(xt).
Multi-iterate Methods
So far, we have only discussed updates that rely on at most one previous iterate
of
xt (or
λt or
μt) to regularize updates with a
penalty term
D, thus defining “trust-regions” in which the approximation
f^≈f is assumed to be valid. We may also choose update
penalties that rely on additional history of the solution candidates
(xt,xt−1,...).
Momentum
An example of a multi-iterate approach is given by the classical “Momentum”
variant of gradient descent. Consider, for example, a penalty term
Dt
that quadratically penalizes step-sizes with a linear term that encourages steps
in same continued direction, as in
Dt(x)=η1(21x−xt22−ξ⟨x−xt,xt−xt−1⟩),
where
ξ∈(0,1). Alternatively, consider a quadratic penalty for the
difference between the proposed update and the previous update with decay
ξ, as in
Dt(x)=2η1(x−xt)−ξ(xt−xt−1)22.
In either case,
∇Dt(x)=η1((x−xt)−ξ(xt−xt−1)).
If we solve Eq. (2) by setting
∇(f^t+Dt)=0 for
either choice of
Dt, the resulting update rule is
xt+1=xt+ξ(xt−xt−1)−η∇f^t,
which can be decomposed, with an additional state variable
v, to
vt+1xt+1=ξvt−η∇f^t,=xt+vt+1.(8)
This update rule is the classical “Momentum” algorithm (Botev et. al. (2016))
with decay parameterized by
ξ.
Nth-Order Regularization
There is yet another update penalty
Dt that may be used to derive the
Momentum update rule. Specifically, let
For
n=2, Letting
ξ1=(1−ξ) and
ξ2=ξ, we recover
the standard momentum update.
Surrogate Approximation
As
x varies from
xt to
xt+1, the minimum average error of a
local approximation of
f(x) along this path can be reduced by choosing an
intermediate point
x~t, somewhere between
xt and
xt+1, instead of
xt, about which to approximate the local behavior
of
f.
Nesterov Acceleration
When using Eq. (8), one “zero-cost” (i.e., if we decouple candidate
solutions
xt from the points at which we query
f^) choice of
x~t is given by
x~t=xt+ξvt,
such that
f^t(x)=f(x~t)+⟨∇f(x~t),x−x~t⟩.(10)
Substituting Eq. (10) into Eq. (8), we obtain Nesterov’s variant of
gradient descent with momentum:
vt+1xt+1=ξvt−η∇f(xt+ξvt),=xt+vt+1.
Dealing with Constraints
Consider the basic (constrained) optimization problem
minimizesubjecttof(x)g(x)⪯0,h(x)=0,
for vector-valued
g and
h.
In terms of the corresponding Lagrangian
L, the primal problem
may be written
xminimize(λ,μmaxsubjecttoL(x,λ,μ))λ⪰0,(12)
where
L(x,λ,μ)=f(x)+λ⊤g(x)+μ⊤h(x).
Intuitively, given that
λ and
μ are chosen adversarially
(i.e., after
x is fixed), the problem is to choose
x such that the
constraints on
g(x) and
h(x) are satisfied (otherwise, the objective can
be made unboundedly positive by an adversary’s choice of
λ,μ).
Within this “feasible set” of
x values,
f should be minimized.
Primal-Dual
We may iteratively approximate Eq. (12) with a sequence of subproblems in the form of Eq. (2):
where
max is taken element-wise and the gradients are taken with respect to
x (and these gradient components remain uncontracted with the dimensions of
λ or
μ).
In practice, it is common to eliminate the mutual dependence between variables
in Eq. (14) by replacing
xt+1↦xt,
λt+1↦λt, and
μt+1↦μt on the right-hand side
of each equation, thus yielding the standard primal-dual algorithm, which
maintains iterates for the dual variables
λ and
μ in addition
to the primal variable
x. The error of this approximation has order
O(η(α+β)), though this is not strictly necessary.
When
ηα<∣∇g(xt)∣2 and
ηβ<∣∇h(xt)∣2,
the true solution to Eq. (14) may be found by iterating the recursive
map
For convex functions
f,
g, and
h, and sufficiently small
η,α,β, iterating subproblem Eq. (14) will cause
x,
λ, and
μ to converge to finite values and solve the target
constrained optimization problem Eq. (12).
Generalizing Fletcher’s Method
In this section, we show how a rather interesting penalty choice for the dual
variable
λ, as used above, completely eliminates the need to track
λ as an independent variable all and provides a straight-forward
method for constrained optimization based on local gradients of the objective
and the constraint.
Consider the problem
minimizesubjecttof(x)g(x)≤0,
for vector
x and scalar-valued
f and
g.
Given standard assumptions such as convexity, this problem may be solved the
sequence of subproblems
which, as in Eq. (4), we express using the local, linear approximations
f^ and
g^. Note that we have no need to track the value of
λ between iterates of the above subproblems. This is because, instead
of penalizing the update magnitude
∥λ−λt∥, we penalize
the distance of
λ away from the value that renders
xt a
critical point of the Lagrangian. We have omitted an explicit time-index on
λ despite the fact that its value may change with each iteration.
Solving the above subproblem,
xt+1 has the explicit solution given by
Intuitively, when
g(xt) is positive, in order to make progress towards
the constraint
g≤0, we ensure that the update
xt+1−xt is
aligned with the negative gradient of
g. When
g is negative, and the
constraint already satisfied, the update cannot be too aligned with increasing
g. Subject to these constraints
xt+1 may be chosen to make progress
towards decreasing the objective
f.