11. Tutorials
11.1. Contraction rate of gradient descent
- PEPit.examples.tutorials.wc_gradient_descent_contraction(L, mu, gamma, n, verbose=1)[source]
Consider the convex minimization problem
\[f_\star \triangleq \min_x f(x),\]where \(f\) is \(L\)-smooth and \(\mu\)-strongly convex.
This code computes a worst-case guarantee for gradient descent with fixed step-size \(\gamma\). That is, it computes the smallest possible \(\tau(n, L, \mu, \gamma)\) such that the guarantee
\[\| x_n - y_n \|^2 \leqslant \tau(n, L, \mu, \gamma) \| x_0 - y_0 \|^2\]is valid, where \(x_n\) and \(y_n\) are the outputs of the gradient descent method with fixed step-size \(\gamma\), starting respectively from \(x_0\) and \(y_0\).
In short, for given values of \(n\), \(L\), \(\mu\) and \(\gamma\), \(\tau(n, L, \mu \gamma)\) is computed as the worst-case value of \(\| x_n - y_n \|^2\) when \(\| x_0 - y_0 \|^2 \leqslant 1\).
Algorithm: For \(t\in\{0,1,\ldots,n-1\}\), gradient descent is described by
\[x_{t+1} = x_t - \gamma \nabla f(x_t),\]where \(\gamma\) is a step-size.
Theoretical guarantee: The tight theoretical guarantee is
\[\| x_n - y_n \|^2 \leqslant \max\{(1-L\gamma)^2,(1-\mu \gamma)^2\}^n\| x_0 - y_0 \|^2,\]which is tight on simple quadratic functions.
- Parameters
L (float) – the smoothness parameter.
mu (float) – the strong-convexity parameter.
gamma (float) – step-size.
n (int) – number of iterations.
verbose (int) –
Level of information details to print.
1: No verbose at all.
0: This example’s output.
1: This example’s output + PEPit information.
2: This example’s output + PEPit information + CVXPY details.
- Returns
pepit_tau (float) – worst-case value
theoretical_tau (float) – theoretical value
Example
>>> L = 1 >>> pepit_tau, theoretical_tau = wc_gradient_descent_contraction(L=L, mu=0.1, gamma=1 / L, n=1, verbose=1) (PEP-it) Setting up the problem: size of the main PSD matrix: 4x4 (PEP-it) Setting up the problem: performance measure is minimum of 1 element(s) (PEP-it) Setting up the problem: initial conditions (1 constraint(s) added) (PEP-it) Setting up the problem: interpolation conditions for 1 function(s) function 1 : 2 constraint(s) added (PEP-it) Compiling SDP (PEP-it) Calling SDP solver (PEP-it) Solver status: optimal (solver: MOSEK); optimal value: 0.8100000029204689 *** Example file: worst-case performance of gradient descent with fixed step-sizes in contraction *** PEP-it guarantee: ||x_n - y_n||^2 <= 0.81 ||x_0 - y_0||^2 Theoretical guarantee: ||x_n - y_n||^2 <= 0.81 ||x_0 - y_0||^2