alphaFeedback

WorksComputer Science

Stepsize modulation for cross entropy from local quadratic optimization

AI contributions
Not recorded for this paper
View details
Ancillary data
1 code link
View

Abstract

Two methods are presented that perturb a given learning rate schedule in stochastic gradient descent with cross entropy loss. Both methods use an extra forward pass to estimate various derivatives of the minibatch loss. The first method selects a value ηη by linearising the softmax values and minimizing the squared error 12∣∣y−q−ηq′∣∣F2\tfrac 1 2 ||y - q - ηq'||_F^2, where qq is the matrix representing the softmax values of the minibatch and yy is the matrix with one-hot encodings of the labels. The second method considers a quadratic Taylor approximation of the minibatch loss under the outer approximation of the Hessian. Thus, it minimizes L(0)+ηL′(0)+12η2L′′(0)L(0) + ηL'(0) + \tfrac 1 2 η^2 L''(0). Here, the derivatives L′L' and L′′L'' are computed from the derivatives of the logits (using the outer approximation of the Hessian of the loss). We observe that both methods give very similar values of ηη. Finally, these estimated ηη are used to slightly increase or decrease the learning rate of an existing schedule. The method is evaluated on Cifar10 and Cifar100 datasets for training Resnets, where they decrease the loss faster than the schedule that is perturbed and increase monotonicity. For Cifar10 it also leads to a small improvement of test accuracy, but in Cifar100 test accuracy remains the same.

Introduction

The selection of the learning rate is a very consequential decision when training neural nets. Despite much research in automatically selecting step sizes, typical training with convolutional nets is done with some fixed schedule for which maximum learning rate and weight decays are tuned. In this paper, we ask whether one can modulate the standard cosine schedule using batch dependant stepsizes to improve training. More precisely, can we inspect certain properties of a minibatch and use it to decide whether a bigger or smaller stepsize should be used compared to the scheduled value of the epoch. Can this speed up training and increase test accuracy?

The Polyak stepsize

Consider a loss function L(θ)L(\theta). We aim to find a value of θ\theta that makes LL as small as possible. The gradient descent method starts from an arbitrary θ0\theta_0 and iteratively computes

θt+1=θt−ηt∇L(θt).\theta_{t+1}=\theta_t-\eta_t\nabla L(\theta_t).

Already in 1969, Polyak proposed to automatically select the stepsize using a linear approximation of the loss function [24]. Consider the linear approximation

L(θt−w)≈L(θt)−∇L(θt)⋅w.L(\theta_t-w)\approx L(\theta_t)-\nabla L(\theta_t)\cdot w.

*National Research University Higher School of Economics, Faculty of Computer Science, Moscow, Russia; This work/article is an output of a research project (HSE-BR-2025-024) implemented as part of the Basic Research Program at HSE University. This research was supported in part through computational resources of HPC facilities at HSE University.

†Luxoft Serbia.

For w=ηt∇L(θt)w=\eta_t\nabla L(\theta_t), this simplifies to

L(θt+1)≈L(θt)−ηt∥∇L(θt)∥2L(\theta_{t+1}) \approx L(\theta_t) - \eta_t\lVert\nabla L(\theta_t)\rVert^2

Solving for L(θt+1)≈0L(\theta_{t+1}) \approx0, gives

ηt=L(θ)∥∇L(θt)∥2\eta_t = \frac{L(\theta)}{\lVert\nabla L(\theta_t)\rVert^2}

It was directly clear that if LL is smooth and strongly convex, then gradient descent with this stepsize converges exponentially fast in tt [24]. A bit later, Polyak proved that for all convex functions (possibly non-smooth) this method has O(1/t)O(1/\sqrt{t}) convergence: lim inf⁡tt(L(θt)−L(θ∗))=0\liminf_{t}\sqrt{t}(L(\theta_t)-L(\theta^*))=0.

In machine learning, the above gradients are estimated on small random selections of the training data, called minibatches. This means that for each step, a random approximation Lt(θ)L_t(\theta) of the loss is generated. The Polyak stepsize under this function is called the stochastic Polyak stepsize, for which O(1/t)O(1/t) convergence was proven under star-convexity of the loss [9 theorem 4.4], and this is locally satisfied in deep neural nets [15, 33].

Unfortunately, the Stochastic Polyak stepsize is very unstable and can spike. This often happens in the beginning of training when L(θt)L(\theta_t) is large and the gradients are small (especially if the softmax is used). In the case of cross entropy loss, the curve does not reach zero and is locally convex for most minibatches. Hence, the Polyak stepsize overestimates, as illustrated in Figure 1 and Figure 2.

The Polyak stepsize over estimates on convex strictly positive functions

Figure 1. The Polyak stepsize over estimates on convex strictly positive functions

Comparison between stepsizes

Figure 2. comparison between stepsizes: so-dz (red), cs-dq (green), Polyak (orange), cosine decay (blue).

For this reason, many variants for practical use have been proposed [3, 19, 14, 20, 23, 21]. However, they lead often lead to unstable training, especially when combined with momentum. Moreover, they are not able to replace manual learning rate selection because of sensitive dependencies on newly introduced hyper parameters. (Also for LLMs there are such reports [22].) Perhaps, an exception is the *momo* scheduler from [26]`, which is designed to optimize the loss aggregated from the last few minibatches. It works well with momentum and weight decay. Moreover, it has has only a single hyper parameter that is easy to tune, but it has not been tested systematically against competitors.

Second order methods

Approaches with test points. To select the learning rate, one may consider a quadratic approximation of the loss,

L(θt−w)≈L(θt)−w⋅∇L(θt)+12wTHLw.L(\theta_t-w) \approx L(\theta_t)-w\cdot\nabla L(\theta_t)+\frac{1}{2}w^{\mathsf{T}}H_Lw.

Each optimization method in a typical machinelearning optimizer defines a direction, for example, for basic SGD the direction is w=−η∇L(θt)w=-\eta\nabla L(\theta_t) or with momentum, it is w=−η∇L(θt)−μvt−1w=-\eta\nabla L(\theta_t)-\mu v_{t-1}. After substituting in LL, one obtains an equation of the form f(η)=aη2+bη+cf(\eta)=a\eta^2+b\eta+c from which an optimal stepsize η\eta can be computed. In [5, 34], the coefficients a,b,ca,b,c are obtained from 3 evaluations of ff. Since gradient descent already provides 1 evaluation, this method makes 2 extra forward evaluations, and hence, is %66 slower (assuming a backwards pass takes twice the time of a forward pass). These methods reduce the training loss very fast, but at the expense of the test loss [34]. A similar technique is applied in [5] in which the computed learning rate is smoothed using a moving average and improvements on some fine tuning tasks are reported.2

In [8] it is noted that w⋅∇L(θt)w \cdot\nabla L(\theta_t) is fast to compute, thus to find the coefficients a,b,ca,b,c, only 1 extra forward evaluation is needed. The paper presents an algorithm that is essentially parameter free and provably converges to a stationary point for Lipschitz functions. Unfortunately, they do not report test performance.

Barzilai-Borwein stepsizes. Another approach is to calculate the solution using the available gradient information, thus one needs

ηt=v⋅∇L(θt)vTHLv.(1)\eta_t = \frac{v \cdot\nabla L(\theta_t)}{v^{\mathsf{T}} H_L v}. \tag*{(1)}

In the Barzilai-Borwein method [2] one assumes v=∇L(θt)v = \nabla L(\theta_t) and estimates the above value by

ηt=∥θt−θt−1∥2(θt−θt−1)⋅(∇L(θt)−∇L(θt−1)).\eta_t = \frac{\lVert\theta_t - \theta_{t-1} \rVert^2}{(\theta_t-\theta_{t-1}) \cdot(\nabla L(\theta_t)-\nabla L(\theta_{t-1}))}.

This inspired a number of automated learning rate methods [6, 28, 30]. Again, the method suffers from instability, but [30] results come close to standard methods such as SGD with cosine annealing.

1st order estimates of the 2nd order. In [1], the stepsize (1) is estimated directly with the already computed gradient. The denominator involves the Hessian, which is expensive to compute. However, typical networks of the last decade have wide hidden layers, and this allows for a good approximation with gradients. This is because preactivations of the output neurons are locally linear functions, as explained in many papers about the neural tangent kernels, see for example [12, 17, 25].

For this, consider the loss as a function of output preactivations

L(θ)=L(F(θ)).L(\theta) = \mathcal{L}(F(\theta)).

The Hessians of LL can be written using the Hessians of L\mathcal{L} and the Hessians of the output preactivations FaF_a. Let Jaμ=∂Fa∂θμJ_{a\mu} = \frac{\partial F_a}{\partial\theta_\mu} be the Jacobian of FF.

HL=JHLJ+∑a∂L∂FaHFa.H_L = J H_{\mathcal{L}} J + \sum_a \frac{\partial\mathcal{L}}{\partial F_a} H_{F_a}.

For large neural nets, the spectral norm of the Hessians FaF_a are proportional to O(depth/width)O(\text{depth}/\text{width}), see [25]. In the outer product approximation of HLH_L all these Hessian are neglected and only the 1st term remains, see for example [4 p 243, sect.8.1.6]. In [1] this first term is computed using the available gradient, and (1) is obtained with negligible computational overhead. They show in a few experiments that this reduces the train error better than SGD, but do not report test errors.

Below, we propose a method that uses a single test point to estimate this 2nd order stepsize in the same way.

Other methods

In the paper [18], a wide range of optimizers is modified in a generic way: in each minibatch, the existing learning rate schedule is randomly increased or decreased by a few percentages. Despite its simplicity, this method is reported to consistently increase test error, including on Cifar10 and Resnet18 experiments.

This easy method is similar to other regularization methods like dropout [27] or neftune [13] that increase randomness during training. The motivation is that solutions with wide minima have better generalization and it is argued that these perturbations can help to escape narrow local minima. See [31] for this theory.

Finally, the paper [7] uses a complex algorithm from the field of online convex optimization to select the learning rate. [todo: test error?]

Two proposed stepsizes

We aim to minimize to optimize parameters θ\theta to train a neural nets. For this, a standard run of stochastic gradient descent is applied, which means that we start from a randomly generated θ0\theta_0 and at each step, a minibatch loss Lt(θ)L_t(\theta) is used to update θt\theta_t using

vt=μvt−1+ηt∇Lt(θt−1+μvt−1)+λθt−1,θt=θt−1−vt,(2)\begin{aligned} v_t &= \mu v_{t-1}+\eta_t\nabla L_t(\theta_{t-1}+\mu v_{t-1})+\lambda\theta_{t-1},\\ \theta_t &= \theta_{t-1}-v_t, \tag*{(2)} \end{aligned}

where μ\mu and λ\lambda are the parameters for momentum and weight decay.

Notation. Consider a neural net with noutn_{\mathrm{out}} output neurons and a train set whose examples are denoted by (xα,yα)(x_\alpha,y_\alpha) with Greek indices. For each training example, the label yαy_\alpha is given as a one-hot encoding of the correct label, thus yαc=1y_{\alpha c}=1 if xαx_\alpha belongs to the cc-th class. The preactivations of the output neurons are denoted by the vector f(xα,θ)f(x_\alpha,\theta), where θ\theta is the list of all trainable weights of the net.

We now define the minibatch loss LtL_t. Let

zαi=fi(xα,θ)z_{\alpha i}=f_i(x_\alpha,\theta)
qαi=exp⁡zαi∑j≤noutexp⁡zαjq_{\alpha i}=\frac{\exp z_{\alpha i}}{\sum_{j\le n_{\mathrm{out}}}\exp z_{\alpha j}}

For a list of train examples StS_t, the tt-th minibatch loss is

Lt(θ)=−∑α∈St∑i≤noutyαiln⁡qαi.L_t(\theta)=-\sum_{\alpha\in S_t}\sum_{i\le n_{\mathrm{out}}}y_{\alpha i}\ln q_{\alpha i}.

Notation. We write ∑α\sum_\alpha to denote ∑α∈St\sum_{\alpha\in S_t} and sums over indices i,j,ki,j,k range from 1 to noutn_{\mathrm{out}}.

The second order outer approximated stepsize (so-dz)

Fix tt and let L(η~)=Lt(θt−η~v~t)L(\tilde{\eta})=L_t(\theta_t-\tilde{\eta}\tilde{v}_t). We select the stepsize ηso\eta_{\mathrm{so}} to minimize the quadratic approximation of Lt(η~)L_t(\tilde{\eta}). As explained in subsection 1, we may assume that zαiz_{\alpha i} is linear in η~\tilde{\eta} and we can obtain the derivative from only the gradient. Still, to increase stability, we use a test point.

Let us explain this plan in more details. We have

Lt(η)≈Lt(0)−ηL′(0)+η22L′′(0).L_t(\eta)\approx L_t(0)-\eta L'(0)+\frac{\eta^2}{2}L''(0).

To compute L′(0)L'(0) we view LL as a function of the output preactivations zαiz_{\alpha i} and apply the chain rule. The 2nd derivative L′′(0)L''(0) is computed similarly, while the 2nd derivatives of zαiz_{\alpha i} are neglected, see appendix A for details. Let δij\delta_{ij} be the Kronecker function, which equals 1 if i=ji=j and 0 otherwise.

ηso∗=L′(0)L′′(0)=∑α,i(yαi−qαi)dzαidη∑α,i,j(δij−qαi)qαjdzαidηdzαjdη.\eta_{\mathrm{so}}^*=\frac{L'(0)}{L''(0)} =\frac{\sum_{\alpha,i}(y_{\alpha i}-q_{\alpha i})\frac{d z_{\alpha i}}{d\eta}} {\sum_{\alpha,i,j}(\delta_{ij}-q_{\alpha i})q_{\alpha j}\frac{d z_{\alpha i}}{d\eta}\frac{d z_{\alpha j}}{d\eta}}.

Finally, in this expression, dzαjdη\frac{d z_{\alpha j}}{d\eta} is estimated by evaluating the output preactivations zz with a test update of η\eta using a fixed learning rate ηtest\eta^{\mathrm{test}}. More precisely, let

θttest=θt−μvt−ηtest∇L(θt)−λθt.\theta_t^{\mathrm{test}}=\theta_t-\mu v_t-\eta^{\mathrm{test}}\nabla L(\theta_t)-\lambda\theta_t.

Let qαtestq_\alpha^{\mathrm{test}} and qαq_\alpha be the softmax values evaluated with parameters θttest\theta_t^{\mathrm{test}} and θt\theta_t. Then, estimate dzαdη\frac{d z_\alpha}{d\eta} by (zαtest−zα)/ηtest(z_\alpha^{\mathrm{test}}-z_\alpha)/\eta^{\mathrm{test}}. Thus,

η^so=ηtest∑α,i(yαi−qαi)(zαitest−zαi)∑α,i,j(δij−qαi)qαj(zαitest−zαi)(zαjtest−zαj).(3)\hat{\eta}_{\mathrm{so}}=\eta^{\mathrm{test}} \frac{\sum_{\alpha,i}(y_{\alpha i}-q_{\alpha i})(z_{\alpha i}^{\mathrm{test}}-z_{\alpha i})} {\sum_{\alpha,i,j}(\delta_{ij}-q_{\alpha i})q_{\alpha j}(z_{\alpha i}^{\mathrm{test}}-z_{\alpha i})(z_{\alpha j}^{\mathrm{test}}-z_{\alpha j})}. \tag*{(3)}

This finishes the construction. The pseudocode is given in algorithm 1. In the experiments, we fixed ηtest=5⋅10−5\eta^{\mathrm{test}}=5\cdot10^{-5}.

Algorithm 1 Stepsize modulation algorithms with η^so\hat{\eta}_{\mathrm{so}} and η^cs\hat{\eta}_{\mathrm{cs}}

Initialize: θ0\theta_0 randomly, v0=0v_0 = 0

for epoch =1,…,T= 1, \ldots, T do     sample a fixed-size mini-batch SS and use data {(xα,yα)}α∈S\{(x_\alpha, y_\alpha)\}_{\alpha\in S}     ηepoch←schedulerValue⁡(epoch⁡)\eta_{\mathrm{epoch}} \leftarrow\operatorname{schedulerValue}(\operatorname{epoch})     ϑt←θt−(μvt+λθt)\vartheta_t \leftarrow\theta_t - (\mu v_t + \lambda\theta_t)     zα←f(xα,ϑt)z_\alpha\leftarrow f(x_\alpha, \vartheta_t)     qα←softmax⁡(zα)q_\alpha\leftarrow\operatorname{softmax}(z_\alpha)     Lt←crossEntropy⁡(zS,yS)\mathcal{L}_t \leftarrow\operatorname{crossEntropy}(z_S, y_S)     θtest←ϑt−ηtest∇θLt\theta^{\mathrm{test}} \leftarrow\vartheta_t - \eta^{\mathrm{test}}\nabla_\theta\mathcal{L}_t     zαtest←f(xα,θtest)z_\alpha^{\mathrm{test}} \leftarrow f(x_\alpha, \theta^{\mathrm{test}})     qαtest←softmax⁡(zαtest)q_\alpha^{\mathrm{test}} \leftarrow\operatorname{softmax}(z_\alpha^{\mathrm{test}})     η^←eq (3) or (4) using zS,zStest,qS,qStest\hat{\eta} \leftarrow\text{eq (3) or (4) using } z_S, z_S^{\mathrm{test}}, q_S, q_S^{\mathrm{test}}     ηt+1←modulation⁡(η^,ηepoch)\eta_{t+1} \leftarrow\operatorname{modulation}(\hat{\eta}, \eta_{\mathrm{epoch}})     θt+1←θtest−(ηt+1−ηtest)∇θLt\theta_{t+1} \leftarrow\theta^{\mathrm{test}} - (\eta_{t+1} - \eta^{\mathrm{test}})\nabla_\theta\mathcal{L}_t     vt+1←μvt+λθt+ηt+1∇θLtv_{t+1} \leftarrow\mu v_t + \lambda\theta_t + \eta_{t+1}\nabla_\theta\mathcal{L}_t return θT+1\theta_{T+1}

The closest softmax stepsize (cs-dq)

A linear approximation of the softmax values in η\eta is used to select a value that minimizes the average Euclidean distance to the one-hot encodings yαy_\alpha. Thus we minimize the sum of their 2-norms

12∑α∥yα−qα−ηdqαdη∥2\frac{1}{2}\sum_\alpha\left\|y_\alpha- q_\alpha- \eta\frac{\mathrm{d}q_\alpha}{\mathrm{d}\eta}\right\|^2

Recall that sums over α\alpha range over the tt-th minibatch StS_t. Solving the derivative to η\eta gives

ηcs∗=∑α(yα−qα)⋅dqαdη∑α∥dqαdη∥2\eta_{\mathrm{cs}}^* = \frac{\sum_\alpha(y_\alpha-q_\alpha)\cdot\frac{\mathrm{d}q_\alpha}{\mathrm{d}\eta}}{\sum_\alpha\left\|\frac{\mathrm{d}q_\alpha}{\mathrm{d}\eta}\right\|^2}

Finally, we use the same probe for ηtest\eta^{\mathrm{test}} as before to estimate dqαdη\frac{\mathrm{d}q_\alpha}{\mathrm{d}\eta}.

η^so=ηtest∑α(yα−qα)⋅(qαtest−qα)∑α∥qαtest−qα∥2(4)\hat{\eta}_{\mathrm{so}} = \eta^{\mathrm{test}}\frac{\sum_\alpha(y_\alpha-q_\alpha)\cdot(q_\alpha^{\mathrm{test}}-q_\alpha)}{\sum_\alpha\left\|q_\alpha^{\mathrm{test}}-q_\alpha\right\|^2} \tag*{(4)}

Both stepsizes are close

Despite being derived by different philosophies, the averages of these learning rates are close to each other. Indeed, we trained Resnet18 on Cifar10 with standard SGD (max learning rate 0.02, momentum μ=0.9\mu= 0.9, weight decay λ=0.005\lambda= 0.005) and cosine learning rate schedule. During this run we computed the average values of the Polyak stepsize and the 2 above stepsizes. In figure 2, we compare these stepsizes. We conclude that after halving the Polyak stepsize, these values are close to each other during the middle part of the training.

[To do: discuss fluctuations and compare values during minibatches.]

Practical refinements

Outlier removals in stepsize estimates

If for some training example α\alpha of a minibatch, the softmax values do not seem to improve, then we drop this input in the estimation of η^so\hat{\eta}_{\mathrm{so}} and η^cs\hat{\eta}_{\mathrm{cs}}. More precisely, we drop α\alpha from minibatch StS_t if cos⁡ϕα<1/4\cos\phi_\alpha< 1/4 where

cos⁡ϕα=(yα−qα)⋅(qαtest−qα)∥yα−qα∥∥qαtest−qα∥\cos\phi_\alpha= \frac{(y_\alpha-q_\alpha)\cdot(q_\alpha^{\mathrm{test}}-q_\alpha)}{\|y_\alpha-q_\alpha\|\|q_\alpha^{\mathrm{test}}-q_\alpha\|}
Fraction of removed outliers in the stepsize calculation

Figure 3. Fraction of removed outliers in the stepsize calculation

The effect is small, because only few points satisfy the condition cos⁡(φα)<1/4\cos(\varphi_\alpha) < 1/4, as shown in figure 3. But it seems to help to stabilize the estimates [can we say something more convincing or precise]?

Subsampling and computational overhead

The estimation of the stepsize requires an extra forward pass. This increases the runtime typically by 33%, because the time for a backward pass is usually twice the time of a forward pass.

In our 2nd series of experiments, we took 20 random inputs from the remaining minibatch StS_t, (which had 128 elements, before the above pruning), and estimated the learning rate from them. This reduced the overhead from 33% to about 21% (or better on GPU’s with few cores and fast memory).

Modulate an existing learning rate schedule

The effect of changing the learning rate for a given step also has an effect on future steps, because of momentum. Several papers report that this is a challenge to design automated learning rate schemes, for example in [29 footnote 1 on p7]. Moreover, the several theoretical studies suggest that during initial learning it is beneficial to keep the stepsize larger, in order to avoid parameters θt\theta_t approaching sharp local minima. For these reasons, we focussed on perturbing existing schedules, rather than reconstructing them from scratch.

  • Let ηref,e\eta_{\mathrm{ref},e} be a reference learning schedule evaluated in epoch ee. In experiments we will use cosine decay.

  • Let ηt\eta_t be the stepsize from 1 of the above methods, thus η^so\hat{\eta}_{\mathrm{so}} or η^cs\hat{\eta}_{\mathrm{cs}} at batch tt.

  • Let ηˉt\bar{\eta}_t be the average of ηt\eta_t over last N=50N = 50 batches.

  • Let β=0.05\beta= 0.05 be fixed. [Todo: it turns out that we have only lookahead during experiments of our paper.]

Rather than clipping, a smoothly perturbed version of ηref,e\eta_{\mathrm{ref},e} is obtained by multipliyin it with a the following factor in [1−βπ/2,1+βπ/2][1-\beta\pi/2,1+\beta\pi/2],

ηfinal,t=ηref,e(1+βarctan⁡ηt−ηˉtβηˉt).\eta_{\mathrm{final},t}=\eta_{\mathrm{ref},e}\left(1+\beta\arctan\frac{\eta_t-\bar{\eta}_t}{\beta\bar{\eta}_t}\right).

The arctan function was used because the derivative in the origin equals 1.

Lookahead

In the 1st series of experiments, the lookahead technique from [32] was applied. The idea is to stabilize an existing optimizer Opt (like SGD, AdamW, etc) by letting it first make kk updates and then make a single update of the aggregated “gradients”. The optimizer has 2 parameters kk and α\alpha. We use the default values k=5k = 5 and α=0.8\alpha= 0.8.

More precisely, the optimizer Opt is viewed as a fast optimizer and is used to create a slow optimizer as follows. Let θt\theta_t denote the current parameters of the slow optimizer at the start of its slow step. The fast optimizer is initialized with ϕt,0=θt\phi_{t,0} = \theta_t and computes kk updates ϕt,1,…,ϕt,k\phi_{t,1},\ldots,\phi_{t,k}. Finally, the slow optimizers sets

θt+1=(1−α)θt+αϕt,k.\theta_{t+1}=(1-\alpha)\theta_t+\alpha\phi_{t,k}.

Experiments

We use the well known Resnet18 and Resnet34 models and trained them from scratch on Cifar10 and Cifar100. Data augmentation and the modification of the last hidden layer was applied as is now standard, see for example [10].

The 2 baseline experiments are as follows.

  • Standard SGD with cosine learning rate decay (without warmup). The max-learning rate is 0.02, the momentum parameter is μ=0.9\mu= 0.9, the weight decay is 5e−35e-3 and the minibatch size is 128.

  • Lookahead with the above SGD as fast optimizer. The standard values k=5k = 5 and α=0.8\alpha= 0.8 are used.

We have a default experiment which uses Resnet18 on Cifar10 with 50 epochs. All pictures where generated with this default experiment. The max-learning rate and weight decay parameters reported above where tuned for this experiment. Our 2 stepsizes were designed using this same experiment. However, below we report these baselines for different settings with 100 and 200 epochs, and we also report the experiments with Resnet34 and Cifar100. In all experiments the hyper parameters remain the same and are fixed.

Loss and test error per epoch for CIFAR100 and ResNet18

Figure 4. Loss and test error per epoch. Experiment with CIFAR100 and ResNet18, 50 epochs, lookahead.

NetoptimiserCifar10Cifar100
100 epochs200 epochs100 epochs200 epochs
Resnet18SGD95.256 ± 0.15295.476 ± 0.09978.063 ± 0.23978.649±0.259
la95.287 ± 0.1295.603 ± 0.14978.123 ± 0.29678.543 ± 0.254
la, so-dz95.399±0.12795.608 ± 0.10278.157±0.22978.593 ± 0.241
la, cs-dq95.379 ± 0.09795.673±0.16778.114 ± 0.27778.554 ± 0.204
Resnet34SGD95.342 ± 0.10695.536 ± 0.12778.891 ± 0.24979.357 ± 0.259
la95.471 ± 0.13495.629 ± 0.15378.968±0.26579.537±0.197
la, so-dz95.550 ± 0.10995.711±0.09778.919 ± 0.22579.461 ± 0.174
la, cs-dq95.574±0.10295.663 ± 0.08778.959 ± 0.20479.519 ± 0.256

Table 1. Test accuracy, averaged over 16 repetitions

NetOptimiserCifar10Cifar100
100 epochs200 epochs100 epochs200 epochs
Resnet18SGD95.266 ± 0.16495.552 ± 0.13077.896 ± 0.26278.610 ± 0.404
lookahead95.294 ± 0.14895.520 ± 0.15478.225±0.26378.723±0.179
la, so-dz95.363 ± 0.07195.558 ± 0.14778.176 ± 0.15378.595 ± 0.180
SGD, cs-dq95.425±0.13495.653±0.13578.051 ± 0.21278.353 ± 0.300
Resnet34SGD95.436 ± 0.13295.428 ± 0.19878.833 ± 0.24979.347 ± 0.190
lookahead95.438 ± 0.16595.667 ± 0.13978.863 ± 0.25779.592±0.257
SGD, so-dz95.574±0.15395.625 ± 0.15178.941±0.23679.415 ± 0.141
SGD, cs-dq95.433 ± 0.10795.703±0.15878.876 ± 0.30279.427 ± 0.289

Table 2. Test accuracy averaged over 6 repetitions, subsampling

In all experiments, the hyper parameters of the stepsize η^so\hat{\eta}_{\mathrm{so}} and η^cs\hat{\eta}_{\mathrm{cs}} are ηtest=5⋅10−5\eta^{\mathrm{test}} = 5 \cdot10^{-5}, the perturbation β=0.05\beta= 0.05 and the average stepsize is computed from 50 minibatches. Experiments were performed on V100 GPU’s on the cluster of the Higher School of Economics in Moscow [16]. The code is available here https://github.com/Brbauwens/adaptive_stepsize_modular.

For both the so-dz and cs-dq stepsizes, the initial test error decreases more rapidly and the curve is more monotone. However, recall that this method requires 33% more compute (and 21% more compute with subsampling of the test probe). Especially, this is true when combined with lookahead, see figure 4 for the default experiment. However, near the end, improvement becomes slower.

Our methods often improve error on the test set. In a 1st series of experiments, lookahead was applied and no subsampling was done. All 4 methods were applied to the same minibatches. The best test set accuracies are given in tables 1. For the Cifar10 training set, both the so-dz and cs-dq stepsizes exceed both baselines. Unfortunately, for Cifar100 the results look random.

In a 2nd series of experiments, subsampling was applied and lookahead was switched off. The runs of the baselines were repeated with different random seeds. The results in table 2 suggest that this does not decrease performance. Again for Cifar10, the best results is either for so-dz or cs-dq, but in the case of Resnet34, the gains look random. Also, for Cifar100, the methods do not provide reliable improvements.

Conclusion

Two methods were proposed to automatically generate a stepsize for each minibatch. In η^so\hat{\eta}_{\mathrm{so}} stepsize optimizes a 2nd order approximation of the minibatch loss, and the η^cs\hat{\eta}_{\mathrm{cs}} optimizes the softmax values. We argued theoretical and experimentally that both methods give closely related stepsizes.

These stepsizes were used to improve the cosine decay schedule. Experiments show that they speed up convergence beyond the 20%-33% especially in the middle of the training. Moreover, the decrease is more monotone. They give essentially the same accuracy, and in a few experiments, their best accuracy is improved compared to standard SGD and its combination with lookahead.

Derivation of so-dz stepsize

Fix the minibatch is fixed and we drop subscripts tt. Below, the quantities qq and zz are considered for the updated parameter θt+1\theta_{t+1}, which depends on the updated learning rate through (2), thus q=q(θt+1(η))q=q(\theta_{t+1}(\eta)) and z=z(θt+1(η))z=z(\theta_{t+1}(\eta)).

qαi=exp⁡zαi∑jexp⁡zαjq_{\alpha i}=\frac{\exp z_{\alpha i}}{\sum_j \exp z_{\alpha j}}
L(η~)=L(θ−η~w~).L(\tilde{\eta})=L(\theta-\tilde{\eta}\tilde{w}).

We need to evaluate L′(0)L'(0) and L′′(0)L''(0) and write it as a function of qq and dzdη\frac{dz}{d\eta}. Recall that yαjy_{\alpha j} is the one hot encoding of the label of training input xαx_\alpha. One calculates that

∂qiα∂zjα=(δij−qαi)qαj∂L∂ziα=qαi−yαi∂2L∂ziα∂zjα=(δij−qαi)qαj.(5)\begin{aligned} \frac{\partial q_{i\alpha}}{\partial z_{j\alpha}}&=(\delta_{ij}-q_{\alpha i})q_{\alpha j}\\ \frac{\partial L}{\partial z_{i\alpha}}&=q_{\alpha i}-y_{\alpha i}\\ \frac{\partial^2L}{\partial z_{i\alpha}\partial z_{j\alpha}}&=(\delta_{ij}-q_{\alpha i})q_{\alpha j}. \tag*{(5)} \end{aligned}

We have

L′(0)=∑α,i∂L∂zαidzαidη=∑α,i(qαi−yαi)dzαidη.L'(0)=\sum_{\alpha,i}\frac{\partial L}{\partial z_{\alpha i}}\frac{dz_{\alpha i}}{d\eta} =\sum_{\alpha,i}(q_{\alpha i}-y_{\alpha i})\frac{dz_{\alpha i}}{d\eta}.

To calculate L′′L'', we neglect the 2nd derivatives of the output preactivation zz. Thus,

L′′(0)=∑α,i,j∂L′∂zαjdzαjdη=∑α,i,j∂2L∂zαj∂zαidzαidηdzαjdη=∑α,i,j(δij−qαi)qαjdzαidηdzαjdη.\begin{aligned} L''(0)&=\sum_{\alpha,i,j}\frac{\partial L'}{\partial z_{\alpha j}}\frac{dz_{\alpha j}}{d\eta} =\sum_{\alpha,i,j}\frac{\partial^2L}{\partial z_{\alpha j}\partial z_{\alpha i}}\frac{dz_{\alpha i}}{d\eta}\frac{dz_{\alpha j}}{d\eta}\\ &=\sum_{\alpha,i,j}(\delta_{ij}-q_{\alpha i})q_{\alpha j}\frac{dz_{\alpha i}}{d\eta}\frac{dz_{\alpha j}}{d\eta}. \end{aligned}

References

  1. [1]Dario Balboni and Davide Bacciu. ADLER – an efficient Hessian-based strategy for adaptive learning rate. In Proceedings of the 32nd European Symposium on Artificial Neural Networks, Computational Intelligence and Machine Learning (ESANN), 2024.arxiv.org/abs/2305.16396
  2. [2]Jonathan Barzilai and Jonathan M Borwein. Two-point step size gradient methods. IMA journal of numerical analysis, 8(1):141–148, 1988.DOI
  3. [3]Leonard Berrada, Andrew Zisserman, and M Pawan Kumar. Training neural networks for and by interpolation. In International conference on machine learning, pages 799–809. PMLR, 2020.
  4. [4]Christopher M Bishop and Hugh Bishop. Deep learning: Foundations and concepts, volume 1. Springer, Cham, Switzerland, 2024.
  5. [5]Zhiqi Bu and Shiyun Xu. Gradient descent with generalized Newton’s method. In International Conference on Learning Representations, 2025.arxiv.org/abs/2407.02772
  6. [6]Camille Castera, Jérôme Bolte, Cédric Févotte, and Edouard Pauwels. Second-order step-size tuning of sgd for non-convex optimization. Neural Processing Letters, 54(3):1727–1752, 2022.
  7. [7]Ashok Cutkosky, Aaron Defazio, and Harsh Mehta. Mechanic: A learning rate tuner. In Advances in Neural Information Processing Systems, volume 36, pages 47828–47848, 2023.arxiv.org/abs/2306.00144
  8. [8]Minghan Fu and Fang-Xiang Wu. Qlabgrad: A hyperparameter-free and convergence-guaranteed scheme for deep learning. In Proceedings of the AAAI conference on artificial intelligence, volume 38, pages 12072–12081, 2024.
  9. [9]Robert Gower, Othmane Sebbouh, and Nicolas Loizou. Sgd for structured nonconvex functions: Learning rates, minibatching and interpolation. In International Conference on Artificial Intelligence and Statistics, pages 1315–1323. PMLR, 2021.arxiv.org/abs/2006.10311
  10. [10]Tong He, Zhi Zhang, Hang Zhang, Zhongyue Zhang, Junyuan Xie, and Mu Li. Bag of tricks for image classification with convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 558–567, 2019.arxiv.org/abs/1812.01187
  11. [11]Nikhil Iyer, V. Thejas, Nipun Kwatra, Ramachandran Ramjee, and Muthian Sivathanu. LRTuner: A learning rate tuner for deep neural networks. In 8th ICML Workshop on Automated Machine Learning, 2021.arxiv.org/abs/2105.14526
  12. [12]Arthur Jacot, Gabriel Franck, and Clément Hongler. Neural tangent kernel: Convergence and generalization in neural networks. Advances in neural information processing systems, 31, 2018.arxiv.org/abs/1806.07572
  13. [13]Neel Jain, Ping-yeh Chiang, Yuxin Wen, John Kirchenbauer, Hong-Min Chu, Gowthami Somepalli, Brian Bartoldson, Bhavya Kailkhura, Avi Schwarzschild, Aniruddha Saha, et al. Neptune: Noisy embeddings improve instruction finetuning. In International Conference on Learning Representations, volume 2024, pages 17566–17591, 2024.arxiv.org/abs/2310.05914
  14. [14]Daragh King. Using the polyak step size in training convolutional neural networks. In The Second Tiny Papers Track at ICLR, 2024.
  15. [15]Bobby Kleinberg, Yuanzhi Li, and Yang Yuan. An alternative view: When does sgd escape local minima? In International conference on machine learning, pages 2698–2707. PMLR, 2018.arxiv.org/abs/1802.06175
  16. [16]P. Kostenetskiy, V. Kozyrev, R. Chulkevich, M. Salikova, and R. Mishenin. High-performance computing at hse university. In Parallel Computational Technologies, volume 2891 of Communications in Computer and Information Science, Cham, 2026. Springer.
  17. [17]Chaoyue Liu, Libin Zhu, and Mikhail Belkin. Loss landscapes and optimization in over-parameterized non-linear systems and neural networks. Applied and Computational Harmonic Analysis, 59:85–116, 2022.arxiv.org/abs/2003.00307
  18. [18]Hengyu Liu, Qiang Fu, Lun Du, Tiancheng Zhang, Ge Yu, Shi Han, and Dongmei Zhang. Learning rate perturbation: A generic plugin of learning rate schedule towards flatter local minima. In Proceedings of the 31st ACM International Conference on Information & Knowledge Management, CIKM ’22, pages 4234–4238. Association for Computing Machinery, 2022.arxiv.org/abs/2208.11873
  19. [19]Nicolas Loizou, Sharan Vaswani, Issam Hadj Laradji, and Simon Lacoste-Julien. Stochastic polyak step-size for sgd: An adaptive learning rate for fast convergence. In International Conference on Artificial Intelligence and Statistics, pages 1306–1314. PMLR, 2021.arxiv.org/abs/2002.10542
  20. [20]Dimitris Oikonomou and Nicolas Loizou. Stochastic polyak step-sizes and momentum: Convergence guarantees and practical performance. arXiv preprint arXiv:2406.04142, 2024.arxiv.org/abs/2406.04142
  21. [21]Francesco Orabona and Ryan D’Orazio. New perspectives on the polyak stepsize: Surrogate functions and negative results. arXiv preprint arXiv:2505.20219, 2025.arxiv.org/abs/2505.20219
  22. [23]Antonio Orvieto and Lin Xiao. An adaptive stochastic gradient method with non-negative Gauss-Newton stepsizes. arXiv preprint arXiv:2407.04358, 2024.arxiv.org/abs/2407.04358
  23. [24]Boris Teodorovich Polyak. Minimization of unsmooth functionals. USSR Computational Mathematics and Mathematical Physics, 9(3):14–29, 1969.DOI
  24. [25]Daniel A Roberts, Sho Yaida, and Boris Hanin. The principles of deep learning theory, volume 46. Cambridge University Press Cambridge, MA, USA, 2022.
  25. [26]Fabian Schaipp, Ruben Ohana, Michael Eickenberg, Aaron Defazio, and Robert M. Gower. MoMo: Momentum models for adaptive learning rates. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 43542–43570. PMLR, 2024.arxiv.org/abs/2305.07583
  26. [27]Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1):1929–1958, 2014.
  27. [28]Conghui Tan, Shiqian Ma, Yu-Hong Dai, and Yuqiu Qian. Barzilai–borwein step size for stochastic gradient descent. In Advances in Neural Information Processing Systems (NeurIPS), 2016. Also available as arXiv:1605.04131.arxiv.org/abs/1605.04131
  28. [29]Sharan Vaswani, Aaron Mishkin, Issam Laradji, Mark Schmidt, Gauthier Gidel, and Simon Lacoste-Julien. Painless stochastic gradient: Interpolation, line-search, and convergence rates. Advances in neural information processing systems, 32, 2019.arxiv.org/abs/1905.09997
  29. [30]Zhi-Jun Wang, He-Bei Gao, Xiang-Hong Wang, Shuai-Ye Zhao, Hong Li, and Xiao-Qin Zhang. Adaptive learning rate optimization algorithms with dynamic bound based on barzilai-borwein method. Information Sciences, 634:42–54, 2023.DOI
  30. [31]Zeke Xie, Issei Sato, and Masashi Sugiyama. A diffusion theory for deep learning dynamics: Stochastic gradient descent exponentially favors flat minima. arXiv preprint arXiv:2002.03495, 2020.arxiv.org/abs/2002.03495
  31. [32]Michael Zhang, James Lucas, Jimmy Ba, and Geoffrey E Hinton. Lookahead optimizer: k steps forward, 1 step back. Advances in neural information processing systems, 32, 2019.
  32. [33]Yi Zhou, Junjie Yang, Huishuai Zhang, Yingbin Liang, and Vahid Tarokh. Sgd converges to global minimum in deep learning via star-convex path. arXiv preprint arXiv:1901.00451, 2019.arxiv.org/abs/1901.00451
  33. [34]Yingqiu Zhu, Danyang Huang, Yuan Gao, Rui Wu, Yu Chen, Bo Zhang, and Hansheng Wang. Automatic, dynamic, and nearly optimal learning rate specification via local quadratic approximation. Neural Networks, 141:11–29, 2021.DOI

Paper details

vlnc:W_2tdgu2e3
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

Not recorded for this paper · View statement →

Looking for related papers…
Contents