Search

Search papers and lessons

Cyclical Learning Rates for Training Neural Networks

Leslie N. Smith · 2015

Smith (2015) shows that letting the learning rate rise and fall between two bounds trains neural networks as well as a tuned schedule, often in fewer iterations, and gives a short test to find the bounds.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Optimizers
  • Linear algebra
  • Architectures
  • ReadReady to readNot yet

TL;DR

Training a neural network depends heavily on the learning rate, the size of each step, and the usual advice is to tune it and then shrink it over time. Smith (2015) shows that a learning rate that rises and falls between two bounds, on a fixed triangle wave, trains networks as well as a carefully tuned schedule, often in fewer iterations. The paper also gives a short "LR range test" to find the two bounds, so the method needs almost no tuning. It solves the cost of hunting for a good learning-rate schedule by hand.

Builds on: Stochastic Gradient Descent, Learning Rate · Leads to: Cyclical Learning Rate, SGDR (cosine schedules with restarts)

Why it mattered

The paper turned a common habit into a rule that practitioners could follow. Before it, a learning rate was assumed to fall steadily during training, and setting its schedule took many experiments. The paper's experiments on CIFAR-10 and CIFAR-100 with ResNets, Stochastic Depth networks and DenseNets, and on ImageNet with AlexNet and GoogLeNet, showed that a rising phase is useful, not harmful. The method needs essentially no extra computation, which set it apart from adaptive optimisers that carry a per-parameter cost.

Its ideas reappear in later schedules. The paper itself says the method is most similar to SGDR, which restarts a cosine schedule, so the two are read together.

The problem

Gradient descent steps the parameters against the gradient of the loss, and the learning rate scales each step. Two failures are familiar. If the rate is too small, training crawls. If it is too large, training bounces or diverges. The conventional answer was to pick one value, or a schedule that only decreases it, after running many trials.

Smith's observation is that a decrease is not the only useful shape. A larger rate has a short-term cost, because the parameters move further than they need to, but it can help the optimiser cross flat regions and saddle points of the loss. Citing Dauphin and colleagues, the paper argues that the difficulty of minimising the loss in deep networks comes more from saddle points than from poor local minima, and that a higher rate speeds the crossing. So a schedule that cycles between a low and a high value spends time in the useful range without a manual search.

How it works

The method has four stages, run in order. The diagram shows the pipeline; the steps below trace it.

flowchart LR
  A["LR range test: rise linearly for a few epochs"] --> B["Read off base and max bounds"]
  B --> C["Train with triangular cycles between the bounds"]
  C --> D["Stop at the end of a cycle, where the rate is at its minimum"]
  1. Start from the usual setup. Pick an architecture, a dataset and a batch size. The paper uses a batch of 100 for CIFAR-10, so an epoch of 50,000 images is 500 iterations. Check: the number of iterations per epoch is the number of images divided by the batch size.
  2. Run the LR range test. Let the learning rate rise linearly from a low value to a high one over a few epochs, and record the accuracy against the rate. On CIFAR-10 the paper uses this test to see where the accuracy starts to climb and where it turns ragged. Check: the test takes one short run, not many full runs.
  3. Read the two bounds. The base rate is the value where the accuracy starts to rise, and the max rate is where it becomes rough or falls. For CIFAR-10 the paper uses base 0.001 and max 0.006. Check: the base is where the curve starts to climb, and the max is where it turns rough, so the max is well above the base.
  4. Train on the triangle. The rate climbs linearly from the base to the max over half a cycle, then falls back to the base over the next half. The paper's CIFAR-10 run uses a step size of 2,000 iterations, which is half a cycle, so each cycle is 4,000 iterations. Check: 2,000 iterations is four epochs of 500 iterations each.
  5. Stop at the end of a cycle. The rate is at its minimum there and the accuracy peaks. The paper advises three to five cycles before dropping the bounds, and stopping at the end of a cycle. Check: the stopping point is set by the cycle, not by a loss curve.

A tiny trace with base 0.1, max 0.5 and step size 2 (a cycle of 4 iterations) shows the schedule. At iteration 0 the rate is 0.1, the base. At iteration 1 it is halfway up, 0.3. At iteration 2 it is at the max, 0.5. At iteration 3 it is back to 0.3, and at iteration 4 it is at the base again, 0.1. Check: the rate returns to the base exactly one cycle later.

The math

Let bb be the base rate, MM the max rate, ss the step size (half a cycle, in iterations), and tt the iteration. Define the cycle index and the position inside the cycle:

c(t)=⌊1+t2s⌋,x(t)=∣ts−2c(t)+1∣.c(t) = \left\lfloor 1 + \frac{t}{2s} \right\rfloor, \qquad x(t) = \left| \frac{t}{s} - 2c(t) + 1 \right|.

The triangular policy is

ηt=b+(M−b) max⁡(0,  1−x(t)).\eta_t = b + (M - b)\,\max\big(0,\; 1 - x(t)\big).

Stage check. At t=0t = 0, c=1c = 1 and x=1x = 1, so η0=b\eta_0 = b. At t=st = s, c=1c = 1 and x=0x = 0, so ηs=M\eta_s = M. At t=2st = 2s, c=2c = 2 and x=1x = 1, so η2s=b\eta_{2s} = b again. These are the three points of the walkthrough, and the formula is the triangle wave with a period of 2s2s.

The paper also gives two variants. The triangular2 policy halves the amplitude after each cycle:

ηt=b+(M−b) max⁡(0, 1−x(t))2 c(t)−1.\eta_t = b + \frac{(M - b)\,\max(0,\, 1 - x(t))}{2^{\,c(t) - 1}}.

The exp_range policy scales both bounds down by a factor γt\gamma^t per iteration, so the cycles shrink over time. The paper also tried other window shapes, such as a parabolic (Welch) and a Hann window, and the simple triangle is the one it recommends.

The LR range test has no formula of its own. It is the same triangular schedule run once with ss and the total length set to the length of the test, so the rate climbs from bb to MM in a single pass.

02000400060008000100001200000.0020.0040.006iterationlearning rate
  • triangular, base 0.001, max 0.006
The triangular policy with the paper's CIFAR-10 bounds and a step size of 2,000 iterations. The rate peaks at 0.006 every 4,000 iterations and returns to 0.001 at the end of each cycle.

Results

The paper reports results on several datasets. All numbers below are copied from its tables.

On CIFAR-10 with Caffe's architecture, a fixed learning rate reaches 81.4 percent test accuracy after 70,000 iterations. The triangular2 policy reaches the same 81.4 percent after 25,000 iterations. A decay policy that only lowers the rate reaches 78.5 percent over 25,000 iterations, and the exp policy reaches 79.1 percent over 70,000. The exp_range policy reaches 82.2 percent at 42,000 iterations. The paper uses the decay result as evidence that both raising and lowering the rate matter.

On AlexNet with ImageNet, a fixed rate reaches 58.0 percent after 400,000 iterations and triangular2 reaches 58.4 percent over the same budget. On GoogLeNet, a fixed best guess reaches 63.0 percent after 420,000 iterations, and triangular2 reaches 64.4 percent. The exp_range policy reaches 60.2 percent against 58.2 percent for exp, both after 240,000 iterations.

For residual networks, Table 4 averages five runs. On CIFAR-10, ResNet with its fixed rates reaches between 91.8 and 93.3 percent, and ResNet with CLR reaches 93.6 percent. DenseNet with CLR reaches 94.9 percent against 94.2 to 94.5 percent for fixed rates. On CIFAR-100, DenseNet with CLR reaches 75.9 percent, against 74.5 to 75.3 percent for fixed rates.

What the numbers mean. The gains are largest where the baseline was a rough guess, as in the GoogLeNet run, and smallest where the baseline was already well tuned, as in the AlexNet run, where the difference is only 0.4 points. The method is not uniformly better: with Adam, CLR needed the full 70,000 iterations to get close to the fixed-rate baseline, while with Nesterov it reached 81.3 percent in 25,000. The results are for image classification with convolutional networks and batch normalisation, and the paper does not test recurrent networks.

Limits. The experiments use Caffe and Torch with the bounds the authors chose, the baselines are the published hyperparameters, and only Table 4 averages several runs (five each). The paper states that a theoretical analysis is left for later, and that it has not explored the full range of architectures.

Reading guide

The paper has a short body, so the sections map onto a few prerequisites.

Check yourself

QuestionWith a step size of 1,000 iterations, what are the cycle length and the learning rate at iteration 1,000 if the base is 0.001 and the max is 0.006?Show answer

A cycle is two step sizes, so it is 2,000 iterations. At t=s=1,000t = s = 1{,}000 the position is x=∣1−2+1∣=0x = |1 - 2 + 1| = 0, so the rate is at the max, 0.0060.006. Check: half a cycle is 1,000 iterations, so the max is reached at the end of the first half-cycle.

QuestionUsing the tiny trace with base 0.1, max 0.5 and step size 2, what is the learning rate at iteration 6?Show answer

At t=6t = 6 the cycle index is c=⌊1+6/4⌋=2c = \lfloor 1 + 6/4 \rfloor = 2, and the position is x=∣6/2−2⋅2+1∣=∣3−4+1∣=0x = |6/2 - 2 \cdot 2 + 1| = |3 - 4 + 1| = 0. So the rate is 0.1+0.4⋅(1−0)=0.50.1 + 0.4 \cdot (1 - 0) = 0.5, the max. Check: iteration 6 falls on the peak of the second cycle, which sits at iterations 2, 6, 10 and so on.

QuestionThe paper says a higher learning rate can help even though it may hurt for a while. Explain the argument in terms of saddle points.Show answer

Saddle points are flat in some directions, so the gradient there is small and steps are slow. A larger rate lets the optimiser move across these plateaus faster, even though the larger steps make the loss noisier for a time. A cycle returns to a low rate afterwards, so the optimiser settles into a region it has crossed.

QuestionOn CIFAR-10 the decay policy reaches 78.5 percent and the triangular2 policy reaches 81.4 percent, both over 25,000 iterations. What does the comparison show?Show answer

The decay policy only lowers the rate, and the triangular2 policy both raises and lowers it. Since the second does better with the same budget, the rise matters, not just the fall. This is the paper's evidence that both directions are essential.

QuestionA team has a new architecture and no published learning rate. What does the paper recommend as the first step, and why is it cheaper than a grid search?Show answer

Run the LR range test for a few epochs, with the rate rising linearly from a low to a high value, and read the two bounds off the accuracy curve. It is one short run, while a grid search needs many full training runs, one per candidate rate.

Sources

Read the full paper

Leslie N. Smith, 2015. arXiv:1506.01186