Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Crash Course in Optimization

Terminology

Optimality Conditions

Unconstrained Optimization

Constrained Optimization

Convexity

Algorithms

Gradient Descent

Consider the unconstrained optimization problem min⁡x∈Rnf(x)\min_{x \in \mathbb{R}^n} f(x).

Gradient descent iteration:

xk+1=xk−αk∇f(xk)x^{k+1} = x^k - \alpha_k \nabla f(x^k)

Theorem: Gradient Descent for Strongly Convex Functions

Assume that ff is μ\mu-strongly convex and has LL-Lipschitz continuous gradients (∥∇f(x)−∇f(y)≤L∥x−y∥\|\nabla f(x)-\nabla f(y) \leq L \|x-y\|). Using a constant step size αˉ=2L+μ\bar{\alpha} = \frac{2}{L+\mu}, the gradient descent iterates satisfy

∥xk+1−x∗∥≤L−μL+μ∥xk−x∗∥\|x^{k+1} - x^*\| \leq \frac{L-\mu}{L+\mu} \|x^k - x^*\|

where x∗x^* is the unique global minimizer of ff.

Consequently, after KK iterations,

∥xK−x∗∥≤(L−μL+μ)K∥x0−x∗∥\|x^K - x^*\| \leq \left(\frac{L-\mu}{L+\mu}\right)^K \|x^0 - x^*\|

f(xK)−f(x∗)≤L2∥xK−x∗∥2≤L2(L−μL+μ)2K∥x0−x∗∥2f(x^K) - f(x^*) \leq \frac{L}{2} \|x^K - x^*\|^2 \leq \frac{L}{2} \left(\frac{L-\mu}{L+\mu}\right)^{2K} \|x^0 - x^*\|^2

Note: Number of iterations to achieve ε\varepsilon-accuracy (i.e., ∥x−x∗∥≤ε\|x - x^*\| \leq \varepsilon) will be O(Lμlog⁡1ε)O\left(\frac{L}{\mu} \log \frac{1}{\varepsilon}\right).

Constrained Optimization

Consider the constrained optimization problem min⁡x∈Ωf(x)\min_{x \in \Omega} f(x), where Ω\Omega is a convex set. The projected gradient descent iteration is given by

xk+1=PΩ(xk−αk∇f(xk))x^{k+1} = P_\Omega(x^k - \alpha_k \nabla f(x^k))

where PΩ(z)=arg⁡min⁡x∈Ω12∥x−z∥P_\Omega(z) = \arg\min_{x \in \Omega} \frac{1}{2}\|x-z\| is the projection of zz onto Ω\Omega.

Stochastic Gradient Descent (SGD)

Stochastic Optimization

Stochastic optimzation problem is formulated as

min⁡x∈Ωf(x)=Eξ[F(x;ξ)]\min_{x \in \Omega} f(x) = \mathbb{E}_{\xi}[F(x; \xi)]

where ξ\xi is a random variable and F(x;ξ)F(x; \xi) is the sample-wise loss or cost.
Remark: If F(⋅,ξ)F(\cdot, \xi) is convex for every ξ\xi, then ff is also convex.

Stochastic Gradient Descent (SGD)

Given a stochastic gradient estimate g(xk,ξk)g(x^k, \xi^k) at iteration kk, the SGD uodate is

xk+1=xk−λkg(xk,ξk)x^{k+1} = x^k - \lambda_k g(x^k, \xi^k)

Theorem

Example: GD vs SGD

Consider the objective function f(x)f(x) defined as the sum of nn component functions:

f(x)=∑i=1nfi(x)f(x) = \sum_{i=1}^{n} f_i(x)

Assumptions:

GD: updates the parameters using the full gradient at each step:

xk+1=xk−α∇f(xk)=xk−α∑i=1n∇fi(xk)x^{k+1} = x^{k} - \alpha \nabla f(x^k) = x^{k} - \alpha \sum_{i=1}^{n} \nabla f_i(x^k)

SGD: picks an index iki_k uniformly at random from {1,2,…,n}\{1, 2, \dots, n\} and approximates the gradient:

xk+1=xk−α[n∇fik(xk)]x^{k+1} = x^k - \alpha \left[ n \nabla f_{i_k}(x^k) \right]

The estimator is unbiased because:

E[n∇fik(xk)]=n⋅[1n∇f1(xk)+⋯+1n∇fn(xk)]=∇f(xk)\mathbb{E}[n \nabla f_{i_k}(x^k)] = n \cdot \left[ \frac{1}{n} \nabla f_1(x^k) + \dots + \frac{1}{n} \nabla f_n(x^k) \right] = \nabla f(x^k)

Decision: To choose between the two, we compare the total costs:

GD: O(nlog⁡1ϵ)vs.SGD: O(1ϵ)\text{GD: } O(n \log \tfrac{1}{\epsilon}) \quad \text{vs.} \quad \text{SGD: } O(\tfrac{1}{\epsilon})

Conclusion: We prefer SGD when the number of samples nn is very large relative to the desired precision, specifically when n≫1ϵn \gg \frac{1}{\epsilon}.