Stochastic gradient descent

Revision as of 09:28, 13 April 2025 by imported>Cebus (→‎Adam: explain the bias correction)
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Template:Short description Template:Machine learning Stochastic gradient descent (often abbreviated SGD) is an iterative method for optimizing an objective function with suitable smoothness properties (e.g. differentiable or subdifferentiable). It can be regarded as a stochastic approximation of gradient descent optimization, since it replaces the actual gradient (calculated from the entire data set) by an estimate thereof (calculated from a randomly selected subset of the data). Especially in high-dimensional optimization problems this reduces the very high computational burden, achieving faster iterations in exchange for a lower convergence rate.<ref>Template:Cite book</ref>

The basic idea behind stochastic approximation can be traced back to the Robbins–Monro algorithm of the 1950s. Today, stochastic gradient descent has become an important optimization method in machine learning.<ref name="Bottou 1998">Template:Cite book</ref>

BackgroundEdit

{{#invoke:Labelled list hatnote|labelledList|Main article|Main articles|Main page|Main pages}} Template:See also Both statistical estimation and machine learning consider the problem of minimizing an objective function that has the form of a sum: <math display="block">Q(w) = \frac{1}{n}\sum_{i=1}^n Q_i(w),</math> where the parameter <math>w</math> that minimizes <math>Q(w)</math> is to be estimated. Each summand function <math>Q_i</math> is typically associated with the <math>i</math>-th observation in the data set (used for training).

In classical statistics, sum-minimization problems arise in least squares and in maximum-likelihood estimation (for independent observations). The general class of estimators that arise as minimizers of sums are called M-estimators. However, in statistics, it has been long recognized that requiring even local minimization is too restrictive for some problems of maximum-likelihood estimation.<ref>Template:Cite journal</ref> Therefore, contemporary statistical theorists often consider stationary points of the likelihood function (or zeros of its derivative, the score function, and other estimating equations).

The sum-minimization problem also arises for empirical risk minimization. There, <math>Q_i(w)</math> is the value of the loss function at <math>i</math>-th example, and <math>Q(w)</math> is the empirical risk.

When used to minimize the above function, a standard (or "batch") gradient descent method would perform the following iterations: <math display="block">w := w - \eta\,\nabla Q(w) = w - \frac{\eta}{n} \sum_{i=1}^n \nabla Q_i(w).</math> The step size is denoted by <math>\eta</math> (sometimes called the learning rate in machine learning) and here "<math>:=</math>" denotes the update of a variable in the algorithm.

In many cases, the summand functions have a simple form that enables inexpensive evaluations of the sum-function and the sum gradient. For example, in statistics, one-parameter exponential families allow economical function-evaluations and gradient-evaluations.

However, in other cases, evaluating the sum-gradient may require expensive evaluations of the gradients from all summand functions. When the training set is enormous and no simple formulas exist, evaluating the sums of gradients becomes very expensive, because evaluating the gradient requires evaluating all the summand functions' gradients. To economize on the computational cost at every iteration, stochastic gradient descent samples a subset of summand functions at every step. This is very effective in the case of large-scale machine learning problems.<ref>Template:Cite conference</ref>

Iterative methodEdit

File:Stogra.png
Fluctuations in the total objective function as gradient steps with respect to mini-batches are taken.

In stochastic (or "on-line") gradient descent, the true gradient of <math>Q(w)</math> is approximated by a gradient at a single sample: <math display="block">w := w - \eta\, \nabla Q_i(w).</math> As the algorithm sweeps through the training set, it performs the above update for each training sample. Several passes can be made over the training set until the algorithm converges. If this is done, the data can be shuffled for each pass to prevent cycles. Typical implementations may use an adaptive learning rate so that the algorithm converges.<ref>Template:Cite book</ref>

In pseudocode, stochastic gradient descent can be presented as :

Template:Framebox

  • Choose an initial vector of parameters <math>w</math> and learning rate <math>\eta</math>.
  • Repeat until an approximate minimum is obtained:
    • Randomly shuffle samples in the training set.
    • For <math> i=1, 2, ..., n</math>, do:
      • <math> w := w - \eta\, \nabla Q_i(w).</math>

Template:Frame-footer

A compromise between computing the true gradient and the gradient at a single sample is to compute the gradient against more than one training sample (called a "mini-batch") at each step. This can perform significantly better than "true" stochastic gradient descent described, because the code can make use of vectorization libraries rather than computing each step separately as was first shown in <ref>Template:Cite conference</ref> where it was called "the bunch-mode back-propagation algorithm". It may also result in smoother convergence, as the gradient computed at each step is averaged over more training samples.

The convergence of stochastic gradient descent has been analyzed using the theories of convex minimization and of stochastic approximation. Briefly, when the learning rates <math>\eta</math> decrease with an appropriate rate, and subject to relatively mild assumptions, stochastic gradient descent converges almost surely to a global minimum when the objective function is convex or pseudoconvex, and otherwise converges almost surely to a local minimum.<ref name="Bottou 1998"/><ref>Template:Cite journal</ref> This is in fact a consequence of the Robbins–Siegmund theorem.<ref>Template:Cite book </ref>

Linear regressionEdit

Suppose we want to fit a straight line <math>\hat y = w_1 + w_2 x</math> to a training set with observations <math>((x_1, y_1), (x_2, y_2) \ldots, (x_n, y_n))</math> and corresponding estimated responses <math>(\hat y_1, \hat y_2, \ldots, \hat y_n)</math> using least squares. The objective function to be minimized is <math display="block">Q(w) = \sum_{i=1}^n Q_i(w) = \sum_{i=1}^n \left(\hat y_i - y_i\right)^2 = \sum_{i=1}^n \left(w_1 + w_2 x_i - y_i\right)^2.</math> The last line in the above pseudocode for this specific problem will become: <math display="block">\begin{bmatrix} w_1 \\ w_2 \end{bmatrix} \leftarrow

\begin{bmatrix} w_1 \\ w_2 \end{bmatrix}
- \eta \begin{bmatrix} \frac{\partial}{\partial w_1} (w_1 + w_2 x_i - y_i)^2 \\
  \frac{\partial}{\partial w_2} (w_1 + w_2 x_i - y_i)^2 \end{bmatrix} =
\begin{bmatrix} w_1 \\ w_2 \end{bmatrix}
-  \eta  \begin{bmatrix} 2 (w_1 + w_2 x_i - y_i) \\ 2 x_i(w_1 + w_2 x_i - y_i) \end{bmatrix}.</math>Note that in each iteration or update step, the gradient is only evaluated at a single <math>x_i</math>. This is the key difference between stochastic gradient descent and batched gradient descent.

In general, given a linear regression <math>\hat y = \sum_{k\in 1:m} w_k x_k</math> problem, stochastic gradient descent behaves differently when <math>m < n</math> (underparameterized) and <math>m \geq n</math> (overparameterized). In the overparameterized case, stochastic gradient descent converges to <math>\arg\min_{w: w^T x_k =y_k \forall k \in 1:n} \|w - w_0\|</math>. That is, SGD converges to the interpolation solution with minimum distance from the starting <math>w_0</math>. This is true even when the learning rate remains constant. In the underparameterized case, SGD does not converge if learning rate remains constant.<ref>Template:Cite journal</ref>

HistoryEdit

In 1951, Herbert Robbins and Sutton Monro introduced the earliest stochastic approximation methods, preceding stochastic gradient descent.<ref name="rm">Template:Cite journal</ref> Building on this work one year later, Jack Kiefer and Jacob Wolfowitz published an optimization algorithm very close to stochastic gradient descent, using central differences as an approximation of the gradient.<ref>Template:Cite journal</ref> Later in the 1950s, Frank Rosenblatt used SGD to optimize his perceptron model, demonstrating the first applicability of stochastic gradient descent to neural networks.<ref>Template:Cite journal</ref>

Backpropagation was first described in 1986, with stochastic gradient descent being used to efficiently optimize parameters across neural networks with multiple hidden layers. Soon after, another improvement was developed: mini-batch gradient descent, where small batches of data are substituted for single samples. In 1997, the practical performance benefits from vectorization achievable with such small batches were first explored,<ref>Template:Cite conference</ref> paving the way for efficient optimization in machine learning. As of 2023, this mini-batch approach remains the norm for training neural networks, balancing the benefits of stochastic gradient descent with gradient descent.<ref>Template:Cite journal</ref>

By the 1980s, momentum had already been introduced, and was added to SGD optimization techniques in 1986.<ref>Template:Cite journal</ref> However, these optimization techniques assumed constant hyperparameters, i.e. a fixed learning rate and momentum parameter. In the 2010s, adaptive approaches to applying SGD with a per-parameter learning rate were introduced with AdaGrad (for "Adaptive Gradient") in 2011<ref name="duchi2">Template:Cite journal</ref> and RMSprop (for "Root Mean Square Propagation") in 2012.<ref name="rmsprop2">{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> In 2014, Adam (for "Adaptive Moment Estimation") was published, applying the adaptive approaches of RMSprop to momentum; many improvements and branches of Adam were then developed such as Adadelta, Adagrad, AdamW, and Adamax.<ref name="Adam20142">Template:Cite arXiv</ref><ref name="pytorch.org">{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

Within machine learning, approaches to optimization in 2023 are dominated by Adam-derived optimizers. TensorFlow and PyTorch, by far the most popular machine learning libraries,<ref>Template:Cite journal</ref> as of 2023 largely only include Adam-derived optimizers, as well as predecessors to Adam such as RMSprop and classic SGD. PyTorch also partially supports Limited-memory BFGS, a line-search method, but only for single-device setups without parameter groups.<ref name="pytorch.org"/><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

Notable applicationsEdit

Stochastic gradient descent is a popular algorithm for training a wide range of models in machine learning, including (linear) support vector machines, logistic regression (see, e.g., Vowpal Wabbit) and graphical models.<ref>Jenny Rose Finkel, Alex Kleeman, Christopher D. Manning (2008). Efficient, Feature-based, Conditional Random Field Parsing. Proc. Annual Meeting of the ACL.</ref> When combined with the back propagation algorithm, it is the de facto standard algorithm for training artificial neural networks.<ref>LeCun, Yann A., et al. "Efficient backprop." Neural networks: Tricks of the trade. Springer Berlin Heidelberg, 2012. 9-48</ref> Its use has been also reported in the Geophysics community, specifically to applications of Full Waveform Inversion (FWI).<ref>Jerome R. Krebs, John E. Anderson, David Hinkley, Ramesh Neelamani, Sunwoong Lee, Anatoly Baumstein, and Martin-Daniel Lacasse, (2009), "Fast full-wavefield seismic inversion using encoded sources," GEOPHYSICS 74: WCC177-WCC188.</ref>

Stochastic gradient descent competes with the L-BFGS algorithm,Template:Citation needed which is also widely used. Stochastic gradient descent has been used since at least 1960 for training linear regression models, originally under the name ADALINE.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}Template:Dead link</ref>

Another stochastic gradient descent algorithm is the least mean squares (LMS) adaptive filter.

Extensions and variantsEdit

Many improvements on the basic stochastic gradient descent algorithm have been proposed and used. In particular, in machine learning, the need to set a learning rate (step size) has been recognized as problematic. Setting this parameter too high can cause the algorithm to diverge; setting it too low makes it slow to converge.<ref>Template:Cite book</ref> A conceptually simple extension of stochastic gradient descent makes the learning rate a decreasing function Template:Mvar of the iteration number Template:Mvar, giving a learning rate schedule, so that the first iterations cause large changes in the parameters, while the later ones do only fine-tuning. Such schedules have been known since the work of MacQueen on [[K-means clustering|Template:Mvar-means clustering]].<ref>Cited by Template:Cite conference</ref> Practical guidance on choosing the step size in several variants of SGD is given by Spall.<ref>Template:Cite book</ref>

File:Optimizer Animations.gif
A graph visualizing the behavior of a selected set of optimizers, using a 3D perspective projection of a loss function f(x, y)
File:Optimizer Animations Birds-Eye.gif
A graph visualizing the behavior of a selected set of optimizers

Implicit updates (ISGD)Edit

As mentioned earlier, classical stochastic gradient descent is generally sensitive to learning rate Template:Mvar. Fast convergence requires large learning rates but this may induce numerical instability. The problem can be largely solved<ref>Template:Cite journal</ref> by considering implicit updates whereby the stochastic gradient is evaluated at the next iterate rather than the current one: <math display="block">w^\text{new} := w^\text{old} - \eta\, \nabla Q_i(w^\text{new}).</math>

This equation is implicit since <math>w^\text{new}</math> appears on both sides of the equation. It is a stochastic form of the proximal gradient method since the update can also be written as: <math display="block">w^\text{new} := \arg\min_w \left\{ Q_i(w) + \frac{1}{2\eta} \left\|w - w^\text{old}\right\|^2 \right\}.</math>

As an example, consider least squares with features <math>x_1, \ldots, x_n \in\mathbb{R}^p</math> and observations <math>y_1, \ldots, y_n\in\mathbb{R}</math>. We wish to solve: <math display="block">\min_w \sum_{j=1}^n \left(y_j - x_j'w\right)^2,</math> where <math>x_j' w = x_{j1} w_1 + x_{j, 2} w_2 + ... + x_{j,p} w_p</math> indicates the inner product. Note that <math>x</math> could have "1" as the first element to include an intercept. Classical stochastic gradient descent proceeds as follows: <math display="block">w^\text{new} = w^\text{old} + \eta \left(y_i - x_i'w^\text{old}\right) x_i</math>

where <math>i</math> is uniformly sampled between 1 and <math>n</math>. Although theoretical convergence of this procedure happens under relatively mild assumptions, in practice the procedure can be quite unstable. In particular, when <math>\eta</math> is misspecified so that <math>I - \eta x_i x_i'</math> has large absolute eigenvalues with high probability, the procedure may diverge numerically within a few iterations. In contrast, implicit stochastic gradient descent (shortened as ISGD) can be solved in closed-form as: <math display="block">w^\text{new} = w^\text{old} + \frac{\eta}{1 + \eta \left\|x_i\right\|^2} \left(y_i - x_i'w^\text{old}\right) x_i.</math>

This procedure will remain numerically stable virtually for all <math>\eta</math> as the learning rate is now normalized. Such comparison between classical and implicit stochastic gradient descent in the least squares problem is very similar to the comparison between least mean squares (LMS) and normalized least mean squares filter (NLMS).

Even though a closed-form solution for ISGD is only possible in least squares, the procedure can be efficiently implemented in a wide range of models. Specifically, suppose that <math>Q_i(w)</math> depends on <math>w</math> only through a linear combination with features <math>x_i</math>, so that we can write <math>\nabla_w Q_i(w) = -q(x_i'w) x_i</math>, where <math>q() \in\mathbb{R}</math> may depend on <math>x_i, y_i</math> as well but not on <math>w</math> except through <math>x_i'w</math>. Least squares obeys this rule, and so does logistic regression, and most generalized linear models. For instance, in least squares, <math>q(x_i'w) = y_i - x_i'w</math>, and in logistic regression <math>q(x_i'w) = y_i - S(x_i'w)</math>, where <math>S(u) = e^u/(1+e^u)</math> is the logistic function. In Poisson regression, <math>q(x_i'w) = y_i - e^{x_i'w}</math>, and so on.

In such settings, ISGD is simply implemented as follows. Let <math>f(\xi) = \eta q(x_i'w^\text{old} + \xi \|x_i\|^2)</math>, where <math>\xi</math> is scalar. Then, ISGD is equivalent to: <math display="block">w^\text{new} = w^\text{old} + \xi^\ast x_i,~\text{where}~\xi^\ast = f(\xi^\ast).</math>

The scaling factor <math>\xi^\ast\in\mathbb{R}</math> can be found through the bisection method since in most regular models, such as the aforementioned generalized linear models, function <math>q()</math> is decreasing, and thus the search bounds for <math>\xi^\ast</math> are <math>[\min(0, f(0)), \max(0, f(0))]</math>.

MomentumEdit

Template:Anchor

Further proposals include the momentum method or the heavy ball method, which in ML context appeared in Rumelhart, Hinton and Williams' paper on backpropagation learning<ref name="Rumelhart1986">Template:Cite journal</ref> and borrowed the idea from Soviet mathematician Boris Polyak's 1964 article on solving functional equations.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Stochastic gradient descent with momentum remembers the update Template:Math at each iteration, and determines the next update as a linear combination of the gradient and the previous update:<ref name="Sutskever2013">Template:Cite conference</ref><ref name="SutskeverPhD">Template:Cite thesis</ref> <math display="block">\Delta w := \alpha \Delta w - \eta\, \nabla Q_i(w)</math> <math display="block">w := w + \Delta w </math> that leads to: <math display="block">w := w - \eta\, \nabla Q_i(w) + \alpha \Delta w </math>

where the parameter <math>w</math> which minimizes <math>Q(w)</math> is to be estimated, <math>\eta</math> is a step size (sometimes called the learning rate in machine learning) and <math>\alpha</math> is an exponential decay factor between 0 and 1 that determines the relative contribution of the current gradient and earlier gradients to the weight change.

The name momentum stems from an analogy to momentum in physics: the weight vector <math>w</math>, thought of as a particle traveling through parameter space,Template:R incurs acceleration from the gradient of the loss ("force"). Unlike in classical stochastic gradient descent, it tends to keep traveling in the same direction, preventing oscillations. Momentum has been used successfully by computer scientists in the training of artificial neural networks for several decades.<ref name="Zeiler 2012">Template:Cite arXiv</ref> The momentum method is closely related to underdamped Langevin dynamics, and may be combined with simulated annealing.<ref name="Borysenko2021">Template:Cite journal</ref>

In mid-1980s the method was modified by Yurii Nesterov to use the gradient predicted at the next point, and the resulting so-called Nesterov Accelerated Gradient was sometimes used in ML in the 2010s.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

AveragingEdit

Averaged stochastic gradient descent, invented independently by Ruppert and Polyak in the late 1980s, is ordinary stochastic gradient descent that records an average of its parameter vector over time. That is, the update is the same as for ordinary stochastic gradient descent, but the algorithm also keeps track of<ref>Template:Cite journal</ref>

<math display="block">\bar{w} = \frac{1}{t} \sum_{i=0}^{t-1} w_i.</math>When optimization is done, this averaged parameter vector takes the place of Template:Mvar.

AdaGradEdit

AdaGrad (for adaptive gradient algorithm) is a modified stochastic gradient descent algorithm with per-parameter learning rate, first published in 2011.<ref name="duchi">Template:Cite journal</ref> Informally, this increases the learning rate for Template:Clarify and decreases the learning rate for ones that are less sparse. This strategy often improves convergence performance over standard stochastic gradient descent in settings where data is sparse and sparse parameters are more informative. Examples of such applications include natural language processing and image recognition.<ref name="duchi"/>

It still has a base learning rate Template:Mvar, but this is multiplied with the elements of a vector Template:Math which is the diagonal of the outer product matrix

<math display="block">G = \sum_{\tau=1}^t g_\tau g_\tau^\mathsf{T}</math>

where <math>g_\tau = \nabla Q_i(w)</math>, the gradient, at iteration Template:Mvar. The diagonal is given by

<math display="block">G_{j,j} = \sum_{\tau=1}^t g_{\tau,j}^2.</math>This vector essentially stores a historical sum of gradient squares by dimension and is updated after every iteration. The formula for an update is nowTemplate:Efn <math display="block">w := w - \eta\, \mathrm{diag}(G)^{-\frac{1}{2}} \odot g</math> or, written as per-parameter updates, <math display="block">w_j := w_j - \frac{\eta}{\sqrt{G_{j,j}}} g_j.</math> Each Template:Math gives rise to a scaling factor for the learning rate that applies to a single parameter Template:Math. Since the denominator in this factor, <math display="inline">\sqrt{G_i} = \sqrt{\sum_{\tau=1}^t g_\tau^2}</math> is the 2 norm of previous derivatives, extreme parameter updates get dampened, while parameters that get few or small updates receive higher learning rates.<ref name="Zeiler 2012"/>

While designed for convex problems, AdaGrad has been successfully applied to non-convex optimization.<ref>Template:Cite journal</ref>

RMSPropEdit

RMSProp (for Root Mean Square Propagation) is a method invented in 2012 by James Martens and Ilya Sutskever, at the time both PhD students in Geoffrey Hinton's group, in which the learning rate is, like in Adagrad, adapted for each of the parameters. The idea is to divide the learning rate for a weight by a running average of the magnitudes of recent gradients for that weight.<ref name=rmsprop>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Unusually, it was not published in an article but merely described in a Coursera lecture.Template:Citation needed Citation 1: https://deepai.org/machine-learning-glossary-and-terms/rmsprop#:~:text=The%20RMSProp%20algorithm%20was%20introduced,its%20effectiveness%20in%20various%20applications. Citation 2: this video at 36:37 https://www.youtube.com/watch?v=-eyhCTvrEtE&t=36m37s

So, first the running average is calculated in terms of means square,

<math display="block">v(w,t):=\gamma v(w,t-1) + \left(1-\gamma\right) \left(\nabla Q_i(w)\right)^2</math>

where, <math>\gamma</math> is the forgetting factor. The concept of storing the historical gradient as sum of squares is borrowed from Adagrad, but "forgetting" is introduced to solve Adagrad's diminishing learning rates in non-convex problems by gradually decreasing the influence of old data.Template:Cn

And the parameters are updated as,

<math display="block">w:=w-\frac{\eta}{\sqrt{v(w,t)}}\nabla Q_i(w)</math>

RMSProp has shown good adaptation of learning rate in different applications. RMSProp can be seen as a generalization of Rprop and is capable to work with mini-batches as well opposed to only full-batches.<ref name="rmsprop" />

AdamEdit

Adam<ref name="Adam2014">Template:Cite arXiv</ref> (short for Adaptive Moment Estimation) is a 2014 update to the RMSProp optimizer combining it with the main feature of the Momentum method.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> In this optimization algorithm, running averages with exponential forgetting of both the gradients and the second moments of the gradients are used. Given parameters <math> w^ {(t)} </math> and a loss function <math> L ^ {(t)} </math>, where <math> t </math> indexes the current training iteration (indexed at <math> 1 </math>), Adam's parameter update is given by:

<math display="block">m_w ^ {(t)} := \beta_1 m_w ^ {(t-1)} + \left(1 - \beta_1\right) \nabla _w L ^ {(t-1)} </math> <math display="block">v_w ^ {(t)} := \beta_2 v_w ^ {(t-1)} + \left(1 - \beta_2\right) \left(\nabla _w L ^ {(t-1)} \right)^2 </math>

<math display="block">\hat{m}_w ^ {(t)} = \frac{m_w ^ {(t)}}{1 - \beta_1^t} </math> <math display="block">\hat{v}_w ^ {(t)} = \frac{ v_w ^ {(t)}}{1 - \beta_2^t} </math>

<math display="block">w ^ {(t)} := w ^ {(t-1)} - \eta \frac{\hat{m}_w^{(t)}}{\sqrt{\hat{v}_w^{(t)}} + \varepsilon} </math> where <math>\varepsilon</math> is a small scalar (e.g. <math>10^{-8}</math>) used to prevent division by 0, and <math>\beta_1</math> (e.g. 0.9) and <math>\beta_2</math> (e.g. 0.999) are the forgetting factors for gradients and second moments of gradients, respectively. Squaring and square-rooting is done element-wise.

As the exponential moving averages of the gradient <math> m_w ^ {(t)}</math> and the squared gradient <math> v_w ^ {(t)}</math> are initialized with a vector of 0's, there would be a bias towards zero in the first training iterations. A factor <math>\tfrac{1}{1 - \beta_{1/2}^t}</math> is introduced to compensate this bias and get better estimates <math>\hat{m}_w ^ {(t)}</math> and <math>\hat{v}_w ^ {(t)}</math>.

The initial proof establishing the convergence of Adam was incomplete, and subsequent analysis has revealed that Adam does not converge for all convex objectives.<ref>Template:Cite conference</ref><ref>Template:Cite thesis</ref> Despite this, Adam continues to be used due to its strong performance in practice.<ref>Template:Cite conference</ref>

VariantsEdit

The popularity of Adam inspired many variants and enhancements. Some examples include:

|CitationClass=web }}</ref> AdamX<ref>Template:Cite journal</ref> further improves convergence over AMSGrad.

Sign-based stochastic gradient descentEdit

Even though sign-based optimization goes back to the aforementioned Rprop, in 2018 researchers tried to simplify Adam by removing the magnitude of the stochastic gradient from being taken into account and only considering its sign.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Template:Expand section

Backtracking line searchEdit

Backtracking line search is another variant of gradient descent. All of the below are sourced from the mentioned link. It is based on a condition known as the Armijo–Goldstein condition. Both methods allow learning rates to change at each iteration; however, the manner of the change is different. Backtracking line search uses function evaluations to check Armijo's condition, and in principle the loop in the algorithm for determining the learning rates can be long and unknown in advance. Adaptive SGD does not need a loop in determining learning rates. On the other hand, adaptive SGD does not guarantee the "descent property" – which Backtracking line search enjoys – which is that <math>f(x_{n+1})\leq f(x_n)</math> for all n. If the gradient of the cost function is globally Lipschitz continuous, with Lipschitz constant L, and learning rate is chosen of the order 1/L, then the standard version of SGD is a special case of backtracking line search.

Second-order methodsEdit

A stochastic analogue of the standard (deterministic) Newton–Raphson algorithm (a "second-order" method) provides an asymptotically optimal or near-optimal form of iterative optimization in the setting of stochastic approximationTemplate:Citation needed. A method that uses direct measurements of the Hessian matrices of the summands in the empirical risk function was developed by Byrd, Hansen, Nocedal, and Singer.<ref>Template:Cite journal</ref> However, directly determining the required Hessian matrices for optimization may not be possible in practice. Practical and theoretically sound methods for second-order versions of SGD that do not require direct Hessian information are given by Spall and others.<ref>Template:Cite journal</ref><ref>Template:Cite journal</ref><ref>Template:Cite book</ref> (A less efficient method based on finite differences, instead of simultaneous perturbations, is given by Ruppert.<ref>Template:Cite journal</ref>) Another approach to the approximation Hessian matrix is replacing it with the Fisher information matrix, which transforms usual gradient to natural.<ref>Template:Cite journal</ref> These methods not requiring direct Hessian information are based on either values of the summands in the above empirical risk function or values of the gradients of the summands (i.e., the SGD inputs). In particular, second-order optimality is asymptotically achievable without direct calculation of the Hessian matrices of the summands in the empirical risk function. When the objective is a nonlinear least-squres loss <math display="block"> Q(w) = \frac{1}{n} \sum_{i=1}^n Q_i(w) = \frac{1}{n} \sum_{i=1}^n (m(w;x_i)-y_i)^2, </math> where <math>m(w;x_i)</math> is the predictive model (e.g., a deep neural network) the objective's structure can be exploited to estimate 2nd order information using gradients only. The resulting methods are simple and often effective<ref>Template:Cite conference</ref>


Approximations in continuous timeEdit

For small learning rate <math display="inline">\eta</math> stochastic gradient descent <math display="inline">(w_n)_{n \in \N_0}</math> can be viewed as a discretization of the gradient flow ODE

<math display="block">\frac{d}{dt} W_t = -\nabla Q(W_t)</math>

subject to additional stochastic noise. This approximation is only valid on a finite time-horizon in the following sense: assume that all the coefficients <math display="inline">Q_i </math> are sufficiently smooth. Let <math display="inline">T >0 </math> and <math display="inline">g: \R^d \to \R </math> be a sufficiently smooth test function. Then, there exists a constant <math display="inline">C>0 </math> such that for all <math display="inline">\eta >0 </math>

<math display="block">\max_{k=0, \dots, \lfloor T/\eta \rfloor } \left|\mathbb E[g(w_k)]-g(W_{k \eta})\right| \le C \eta,</math>

where <math display="inline">\mathbb E </math> denotes taking the expectation with respect to the random choice of indices in the stochastic gradient descent scheme.

Since this approximation does not capture the random fluctuations around the mean behavior of stochastic gradient descent solutions to stochastic differential equations (SDEs) have been proposed as limiting objects.<ref>Template:Cite journal</ref> More precisely, the solution to the SDE

<math display="block">d W_t = - \nabla \left(Q(W_t)+\tfrac 1 4 \eta |\nabla Q(W_t)|^2\right)dt + \sqrt \eta \Sigma (W_t)^{1/2} dB_t,</math>

for <math display="block">\Sigma(w) = \frac{1}{n^2} \left(\sum_{i=1}^n Q_i(w)-Q(w)\right)\left(\sum_{i=1}^n Q_i(w)-Q(w)\right)^T </math> where <math display="inline">dB_t </math> denotes the Ito-integral with respect to a Brownian motion is a more precise approximation in the sense that there exists a constant <math display="inline">C>0 </math> such that

<math display="block">\max_{k=0, \dots, \lfloor T/\eta \rfloor } \left|\mathbb E[g(w_k)]-\mathbb E [g(W_{k \eta})]\right| \le C \eta^2.</math>

However this SDE only approximates the one-point motion of stochastic gradient descent. For an approximation of the stochastic flow one has to consider SDEs with infinite-dimensional noise.<ref> Template:Cite arXiv</ref>

See alsoEdit

NotesEdit

Template:Notelist

ReferencesEdit

Template:Reflist

Further readingEdit

External linksEdit

  • {{#invoke:citation/CS1|citation

|CitationClass=web }}Template:Cbignore

Template:Artificial intelligence navbox