Gradient descent

Let $f: \R^n \to \R$ be convex.

Problem

$$ \begin{align*} \text{Minimise } & f(\v x) \\ \text{over } & \v x\in\R^n. \end{align*} $$

A local minimum is a global minimum. The idea is to take steps along $-\nabla f(x)$ direction. Then roughly $$ \begin{align*} f(x - \epsilon\nabla f(x)) \approx f(x) - \epsilon |\nabla f(x)|^2 < f(x). \end{align*} $$

Gradient descent algorithm open_in_new
  1. For $t=0$, start from an initial point $x_0$.

  2. Repeat until some criterion is satisfied: at some $t$,

    1. Choose a descent direction $\v v_t$ such that $\nabla f(x_t)^T \v v_t < 0$.

    2. Choose a step size $\epsilon_t$.

    3. Update $x_{t+1} = x_t + \epsilon_t v_t$.

Smoothness and strong convexity in gradient descent open_in_new

Definition (smoothness, strongly convexity) open_in_new

Let $f: \R^n \to \R$ be twice differentiable and $\alpha,\beta>0$.

  • $f$ is said to be $\alpha$-strongly convex if $\nabla^2 f(x)$ $\succeq$ $\alpha I$ for all $x\in\R^n$.

  • $f$ is said to be $\beta$-smooth if $\nabla^2 f(x)$ $\preceq$ $\beta I$ for all $x\in\R^n$.

A $\alpha$-strongly convex function cannot change too slowly, and a $\beta$-smooth function cannot change too quickly. This is illustrated in the following theorem:

Theorem (bounds on smooth and strongly convex functions) open_in_new

Let $\v x,\v y\in\R^n$. If $f$ is $\beta$-smooth, then $$ \begin{align*} f(\v y) \leq f(\v x) + \nabla f(\v x)^T (\v y - \v x) + \frac{\beta}{2}|\v x-\v y|^2. \end{align*} $$ If $f$ is $\alpha$-strongly convex, then $$ \begin{align*} f(\v y) \geq f(\v x) + \nabla f(\v x)^T (\v y - \v x) + \frac{\alpha}{2}|\v x - \v y|^2. \end{align*} $$

Proof

Corollary (gradient descent step of smooth function) open_in_new

If $f$ is $\beta$-smooth, then $$ \begin{align*} f\Big(\v x - \frac{1}{\beta}\nabla f(\v x)\Big) \leq f(\v x) - \frac{1}{2\beta}|\nabla f(\v x)|^2 \end{align*} $$

Proof: plug in $\v y = \v x - \frac{1}{\beta}\nabla f(\v x)$ to the previous theorem.

This shows that we are guaranteed to reduce the objective function value going from $\v x$ to $\v x - \frac{1}{\beta} \nabla f(\v x)$, e.g. we do not overshoot.

Theorem (lower bound for minimum value in strongly convex functions) open_in_new

Let $f$ be $\alpha$-strongly convex. Let $p^\ast = \inf_\v x f(\v x)$ be the optimal value.

For any $\v x\in\R^n$, $$ \begin{align*} p^\ast \geq f(\v x) - \frac{1}{2\alpha} |\nabla f(\v x)|^2. \end{align*} $$

Proof

This shows that if $\nabla f(\v x)$ is close to zero (say $|\nabla f(\v x)| < \sqrt{2\alpha\epsilon}$), then $f(\v x)$ is close to optimal ($f(\v x) \leq p^\ast + \epsilon$).

Theorem (convergence of gradient descent for strongly convex and smooth functions) open_in_new

If $f$ is $\alpha$-strongly convex and $\beta$-smooth that is minimised at $x^\ast$, then the gradient descent with constant step size $1/\beta$, i.e. $$ \begin{align*} \v x_{t+1} = \v x_t - \frac{1}{\beta}\nabla f(\v x) \end{align*} $$ satisfies $$ \begin{align*} f(\v x_t) - f(x^\ast) \leq \left(1-\frac{\alpha}{\beta}\right)^t (f(\v x_0) - f(\v x^\ast)). \end{align*} $$ A more common but looser bound is $$ \begin{align*} f(\v x_t) - f(x^\ast) \leq e^{-(\alpha/\beta)t}(f(\v x_0) - f(\v x^\ast)). \end{align*} $$

Proof

To ensure $f(\v x_t) - f(\v x^\ast) \leq \epsilon$, we need $t = (\beta/\alpha)\log((f(\v x_0) - f(\v x^\ast))/\epsilon)$.

  • The relation $t\sim \log (1/\epsilon)$ is called linear convergence.

  • The ratio $\beta/\alpha > 1$ is called the condition number. The closer it is to 1, the faster the convergence.

Newton's method open_in_new

The update rule in Newton's method is $$ \begin{align*} \v x_{t+1} = \v x_t - (\nabla^2 f(\v x_t))\inv \nabla f(\v x_t) \end{align*} $$

Motivation for Newton's method open_in_new

We approximate using the second-order Taylor expansion $$ \begin{align*} f(\v y) \approx f(\v x_t) + \nabla f(\v x_t)^T (\v y - \v x_t) + \frac{1}{2} (\v y - \v x_t)^T \nabla^2 f(\v x_t) (\v y - \v x_t) \end{align*} $$ and set $\v x_{t+1}$ to minimise the right hand side $$ \begin{align*} \v x_{t+1} = \arg\min_{\v y} \left[f(\v x_t) + \nabla f(\v x_t)^T (\v y - \v x_t) + \frac{1}{2} (\v y - \v x_t)^T \nabla^2 f(\v x_t) (\v y - \v x_t)\right]. \end{align*} $$ Since the second-order approximation is convex, we set the derivative to zero: $$ \begin{align*} 0 &= \nabla f(\v x_t) + \nabla^2 f(\v x_t) (\v y - \v x_t) \\ \v y &= \v x_t - (\nabla^2 f(\v x_t))\inv \nabla f(\v x_t). \end{align*} $$

For $f: \R \to \R$, this is the same as trying to find the root of $f'$ using a linear approximation: $$ \begin{align*} x_{t+1} = x_t - \frac{f'(x_t)}{f''(x_t)}. \end{align*} $$

Definition (matrix norm) open_in_new

For some $n\times n$ real matrix $A$, denote $\|A\|$ as the smallest $a\geq 0$ such that $|A\v z| \leq a|\v z|$ for all $\v z\in\R^n$.

For positive semidefinite matrix, $\|A\|$ is the largest eigenvalue.

Theorem (convergence of gradient descent using Newton's method) open_in_new

Suppose $f$ is a twice-differentiable $\alpha$-strongly convex function for $\alpha>0$, minimised at $x^\ast$.

Suppose further that the Hessian of $f$ is $l$-Lipschitz, i.e. for all $\v x,\v y\in\R^n$, $\|\nabla^2 f(\v x) - \nabla^2 f(\v y)\| \leq l|\v x - \v y|$.

Then Newton's method satisfies $$ \begin{align*} f(x_t) - f(x^\ast) \leq \frac{2\alpha^3}{l^2}\left(\frac{l}{2\alpha^2}|\nabla f(\v x_0)|\right)^{2^{t+1}} \end{align*} $$

Proof (non-examinable)

If $\v x_0$ is close to optimal ($|\nabla f(\v x_0)| < 2\alpha^2/l$), then Newton's method is guaranteed to converge faster than exponentially fast. Otherwise it may fail to converge.

You can first do normal gradient descent, and then Newton's method when it is close enough.

Barrier method open_in_new

Let $f: \R^n\to\R$ be a convex objective function and $f_i: \R^n \to \R$ be linear for $1\leq i\leq m$, i.e. $f_i(\v x) = \v a_i^T \v x - b_i$.

Problem

$$ \begin{align*} \text{Minimise } & f(\v x) \\ \text{over } & \v x\in\R^n \\ \text{subject to } & f_i(\v x) \leq 0 \quad\text{for } 1\leq i\leq m. \end{align*} $$

We convert this to an unconstrained problem

Problem

$$ \begin{align*} \text{Minimise } & f(\v x) + \sum_{i=1}^{m} \phi(f_i(\v x)) \\ \text{over } & \v x\in\R^n. \end{align*} $$

Often we pick $\phi(x) = -\log(-x)$, the logarithmic barrier function, leading to

Problem

$$ \begin{align*} \text{Minimise } & t f(\v x) + \Phi(\v x) \\ \text{over } & \v x\in\R^n \\ \text{where } &\Phi(\v x) = -\sum_{i=1}^{m} \log(-f_i(\v x)). \end{align*} $$

$t>0$ is a parameter to trade-off the relative importance of $f$ and $\Phi$.

This is a convex optimisation problem (Derivation).

Algorithm of the barrier method open_in_new
  1. Find a feasible solution $\v x$ (i.e. satisfying $f_i(\v x)\leq 0$for all $i$) and choose some $t>0$ and $\alpha>1$.

  2. Repeat until $t$ is large enough:

    1. Compute the minimiser $x^\ast(t)$ of $tf(\v x) + \Phi(\v x)$ using Newton's method with initial point $\v x$.

    2. Update $x := x^\ast(t)$ and $t:=\alpha t$.

At each $t$ update, the problem is not changed too much, so Newton's method is expected to converge quickly.