Stochastic variance reduction

From HandWiki
Revision as of 08:14, 27 June 2023 by Pchauhan2001 (talk | contribs) (fixing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Family of optimization algorithms

(Stochastic) variance reduction is an algorithmic approach to minimizing functions that can be decomposed into finite sums. By exploiting the finite sum structure, variance reduction techniques are able to achieve convergence rates that are impossible to achieve with methods that treat the objective as an infinite sum, as in the classical Stochastic approximation setting.

Variance reduction approaches are widely used for training machine learning models such as logistic regression and support vector machines[1] as these problems have finite-sum structure and uniform conditioning that make them ideal candidates for variance reduction.

Finite sum objectives

A function [math]\displaystyle{ f }[/math] is considered to have finite sum structure if it can be decomposed into a summation or average:

[math]\displaystyle{ f(x) = \frac{1}{n}\sum_{i=1}^n f_i(x), }[/math]

where the function value and derivative of each [math]\displaystyle{ f_i }[/math] can be queried independently. Although variance reduction methods can be applied for any positive [math]\displaystyle{ n }[/math] and any [math]\displaystyle{ f_i }[/math] structure, their favorable theoretical and practical properties arise when [math]\displaystyle{ n }[/math] is large compared to the condition number of each [math]\displaystyle{ f_i }[/math], and when the [math]\displaystyle{ f_i }[/math] have similar (but not necessarily identical) Lipschitz smoothness and strong convexity constants.

The finite sum structure should be contrasted with the stochastic approximation setting which deals with functions of the form [math]\displaystyle{ f(\theta) = \operatorname E_{\xi} [F(\theta,\xi)] }[/math] which is the expected value of a function depending on a random variable [math]\displaystyle{ \xi }[/math]. Any finite sum problem can be optimized using a stochastic approximation algorithm by using [math]\displaystyle{ F(\cdot,\xi)=f_\xi }[/math].

Rapid Convergence

Stochastic variance reduced methods without acceleration are able to find a minima of [math]\displaystyle{ f }[/math] within accuracy [math]\displaystyle{ \epsilon\gt }[/math], i.e. [math]\displaystyle{ f(x)-f(x_*)\leq \epsilon }[/math] in a number of steps of the order:

[math]\displaystyle{ O \left( \left( \frac{L}{\mu} + n \right)\log \left( \frac{1}{\epsilon} \right)\right). }[/math]

The number of steps depends only logarithmically on the level of accuracy required, in contrast to the stochastic approximation framework, where the number of steps [math]\displaystyle{ O\bigl( L/(\mu \epsilon)\bigr) }[/math] required grows proportionally to the accuracy required. Stochastic variance reduction methods converge almost as fast as the gradient descent method's [math]\displaystyle{ O\bigl( (L/\mu)\log(1/\epsilon) \bigr) }[/math] rate, despite using only a stochastic gradient, at a [math]\displaystyle{ 1/n }[/math] lower cost than gradient descent.

Accelerated methods in the stochastic variance reduction framework achieve even faster convergence rates, requiring only

[math]\displaystyle{ O \left( \left( \sqrt{\frac{nL}{\mu}} + n \right)\log \left( \frac{1}{\epsilon} \right)\right) }[/math]

steps to reach [math]\displaystyle{ \epsilon }[/math] accuracy, potentially [math]\displaystyle{ \sqrt{n} }[/math] faster than non-accelerated methods. Lower complexity bounds.[2] for the finite sum class establish that this rate is the fastest possible for smooth strongly convex problems.

Approaches

Variance reduction approaches fall within 3 main categories: table averaging methods, full-gradient snapshot methods and dual methods. Each category contains methods designed for dealing with convex, non-smooth, and non-convex problems, each differing in hyper-parameter settings and other algorithmic details.

SAGA

In the SAGA method,[3] the prototypical table averaging approach, a table of size [math]\displaystyle{ n }[/math] is maintained that contains the last gradient witnessed for each [math]\displaystyle{ f_i }[/math] term, which we denote [math]\displaystyle{ g_i }[/math]. At each step, an index [math]\displaystyle{ i }[/math] is sampled, and a new gradient [math]\displaystyle{ \nabla f_i(x_k) }[/math] is computed. The iterate [math]\displaystyle{ x_k }[/math] is updated with:

[math]\displaystyle{ x_{k+1} = x_k - \gamma \left[ \nabla f_i(x_k) - g_i + \frac{1}{n}\sum_{i=1}^n g_i \right], }[/math]

and afterwards table entry [math]\displaystyle{ i }[/math] is updated with [math]\displaystyle{ g_i=\nabla f_i(x_k) }[/math].

SAGA is among the most popular of the variance reduction methods due to its simplicity, easily adaptable theory, and excellent performance. It is the successor of the SAG method,[4] improving on its flexibility and performance.

SVRG

The stochastic variance reduced gradient method (SVRG),[5] the prototypical snapshot method, uses a similar update except instead of using the average of a table it instead uses a full-gradient that is reevaluated at a snapshot point [math]\displaystyle{ \tilde{x} }[/math] at regular intervals of [math]\displaystyle{ m\geq n }[/math] iterations. The update becomes:

[math]\displaystyle{ x_{k+1} = x_k - \gamma [\nabla f_i(x_k) - \nabla f_i(\tilde{x}) + \nabla f(\tilde{x})], }[/math]

This approach requires two stochastic gradient evaluations per step, one to compute [math]\displaystyle{ \nabla f_i(x_k) }[/math] and one to compute [math]\displaystyle{ \nabla f_i(\tilde{x})], }[/math] where-as table averaging approaches need only one.

Despite the high computational cost, SVRG is popular as its simple convergence theory is highly adaptable to new optimization settings. It also has lower storage requirements than tabular averaging approaches, which make it applicable in many settings where tabular methods can not be used.

SDCA

Exploiting the dual representation of the objective leads to another variance reduction approach that is particularly suited to finite-sums where each term has a structure that makes computing the convex conjugate [math]\displaystyle{ f_{i}^{*}, }[/math] or its proximal operator tractable. The standard SDCA method[6] considers finite sums that have additional structure compared to generic finite sum setting:

[math]\displaystyle{ f(x) = \frac{1}{n}\sum_{i=1}^n f_i(x^Tv_i) + \frac{\lambda}{2}\|x\|^2, }[/math]

where each [math]\displaystyle{ f_i }[/math] is 1 dimensional and each [math]\displaystyle{ v_i }[/math] is a data point associated with [math]\displaystyle{ f_i }[/math]. SDCA solves the dual problem:

[math]\displaystyle{ \max_{\alpha \in \mathbb{R}^n} -\frac{1}{n}\sum_{i=1}^n f_{i}^{*}(-\alpha_i)-\frac{\lambda}{2} \left \| \frac{1}{\lambda n}\sum_{i=1}^n \alpha_i v_i \right \|^2, }[/math]

by a stochastic coordinate ascent procedure, where at each step the objective is optimized with respect to a randomly chosen coordinate [math]\displaystyle{ \alpha_i }[/math], leaving all other coordinates the same. An approximate primal solution [math]\displaystyle{ x }[/math] can be recovered from the [math]\displaystyle{ \alpha }[/math] values:

[math]\displaystyle{ x = \frac{1}{\lambda n}\sum_{i=1}^n \alpha_i v_i }[/math].

This method obtains similar theoretical rates of convergence to other stochastic variance reduced methods, while avoiding the need to specify a step-size parameter. It is fast in practice when [math]\displaystyle{ \lambda }[/math] is large, but significantly slower than the other approaches when [math]\displaystyle{ \lambda }[/math] is small.

Accelerated approaches

Accelerated variance reduction methods are built upon the standard methods above. The earliest approaches make use of proximal operators to accelerate convergence, either approximately or exactly. Direct acceleration approaches have also been developed[7]

Catalyst acceleration

The catalyst framework[8] uses any of the standard methods above as an inner optimizer to approximately solve a proximal operator:

[math]\displaystyle{ x_k \approx \text{argmin}_x \left \{ f(x) + \frac{\kappa}{2} \| x - y_{k-1} \|^2 \right \} }[/math]

after which it uses an extrapolation step to determine the next [math]\displaystyle{ y }[/math]:

[math]\displaystyle{ y_k = x_k +\beta_k (x_k - x_{k-1}) }[/math]

The catalyst method's flexibility and simplicity make it a popular baseline approach. It doesn't achieve the optimal rate of convergence among accelerated methods, it is potentially slower by up to a log factor in the hyper-parameters.

Point-SAGA

Proximal operations may also be applied directly to the [math]\displaystyle{ f_i }[/math] terms to yield an accelerated method. The Point-SAGA method[9] replaces the gradient operations in SAGA with proximal operator evaluations, result in a simple, direct acceleration method:

[math]\displaystyle{ x_{k+1} = \text{prox}^\gamma_j\left(z_k \triangleq x_k +\gamma \left[ g_{j} - \frac{1}{n} \sum_{i=1}^n g_i \right] \right), }[/math]

with the table update [math]\displaystyle{ g_j = \frac{1}{\gamma}(z_k - x_{k+1}) }[/math] performed after each step. Here [math]\displaystyle{ \text{prox}^\gamma_j }[/math] is defined as the proximal operator for the [math]\displaystyle{ j }[/math]th term:

[math]\displaystyle{ \text{prox}^\gamma_j(y) = \text{argmin}_x \left \{ f_j(x) + \frac{1}{2\gamma} \| x - y \|^2 \right \}. }[/math]

Unlike other known accelerated methods, Point-SAGA requires only a single iterate sequence [math]\displaystyle{ x }[/math] to be maintained between steps, and it has the advantage of only having a single tunable parameter [math]\displaystyle{ \gamma }[/math]. It obtains the optimal accelerated rate of convergence for strongly convex finite-sum minimization without additional log factors.

See also

References

  1. "sklearn.linear_model.LogisticRegression". https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html. 
  2. Lan, Guanghui; Zhou, Yi (2018). "An optimal randomized incremental gradient method". Mathematical Programming: Series A and B 171 (1–2): 167–215. doi:10.1007/s10107-017-1173-0. 
  3. Defazio, Aaron; Bach, Francis; Lacoste-Julien, Simon (2014). "SAGA: A Fast Incremental Gradient Method With Support for Non-Strongly Convex Composite Objectives". Neural Information Processing Systems. 
  4. Schmidt, Mark; Le Roux, Nicolas; Bach, Francis (2017). "Minimizing finite sums with the stochastic average gradient". Mathematical Programming 162. 
  5. Johnson, Rie; Zhang, Tong (2013). "Accelerating Stochastic Gradient Descent using Predictive Variance Reduction". Neural Information Processing Systems. https://papers.nips.cc/paper/2013/file/ac1dd209cbcc5e5d1c6e28598e8cbbe8-Paper.pdf. 
  6. Shalev-Shwartz, Shai; Zhang, Tong (2013). "Stochastic Dual Coordinate Ascent Methods for Regularized Loss Minimization". Journal of Machine Learning Research 14. https://www.jmlr.org/papers/volume14/shalev-shwartz13a/shalev-shwartz13a.pdf. 
  7. Lan, Guanghui; Zhou, Yi (2018). "An optimal randomized incremental gradient method". Mathematical Programming: Series A and B 171 (1–2): 167–215. doi:10.1007/s10107-017-1173-0. 
  8. Lin, Hongzhou; Mairal, Julien; Harchaoui, Zaid (2016). "Catalyst Acceleration for First-order Convex Optimization: from Theory to Practice". Journal of Machine Learning Research 18. 
  9. Defazio, Aaron (2016). "A Simple Practical Accelerated Method for Finite Sums". Neural Information Processing Systems.