How Learning Rate Affects the Training of a Neural Network

How does the learning rate affect the training of a neural network

If I had to pick the single hyperparameter that most dramatically affects whether a neural network trains successfully at all, it would be the learning rate. I’ve seen models that never converge, models that explode into NaN losses within a handful of steps, and models that take forever to train — all because of a poorly chosen learning rate. Get this one number right, and everything else about training tends to go much more smoothly. Get it wrong, and no amount of architectural cleverness will save you.

This article explores the learning rate in depth: what it is mathematically, how it shapes the optimization process, the consequences of setting it too high or too low, and the modern techniques used to manage it effectively.

What Is the Learning Rate?

The learning rate ($\eta$ or $\alpha$) is a scalar hyperparameter that controls the size of the steps a neural network’s optimizer takes when updating its weights during training. In gradient-based optimization, the most basic update rule looks like this:

$$ \theta_{t+1} = \theta_t – \eta \nabla_{\theta} \mathcal{L}(\theta_t) $$

Here, $\theta_t$ represents the model’s parameters at step $t$, $\nabla_{\theta} \mathcal{L}(\theta_t)$ is the gradient of the loss function with respect to those parameters, and $\eta$ is the learning rate that scales how large a step is taken in the direction opposite the gradient (since gradients point toward increasing loss, and we want to minimize loss).

An Analogy: Walking Down a Hill

Picture yourself standing on a foggy hillside, trying to reach the valley floor (the point of minimum loss) using only your sense of the ground’s slope beneath your feet. The learning rate is essentially your stride length. Take steps that are too small, and you’ll inch toward the valley at a painfully slow pace. Take steps that are too large, and you risk overshooting the valley entirely, possibly bouncing back and forth across it or even climbing higher up the opposite slope.

The Loss Landscape and Why Learning Rate Matters

Neural network training involves navigating a high-dimensional, non-convex loss surface with countless local minima, saddle points, and plateaus. The learning rate determines how the optimizer traverses this landscape.

graph TD
    A[Initialize Weights] --> B[Compute Gradient]
    B --> C{Learning Rate Size?}
    C -->|Too Small| D[Very Slow Convergence, May Get Stuck]
    C -->|Too Large| E[Overshooting, Oscillation, or Divergence]
    C -->|Well-Tuned| F[Smooth, Efficient Convergence]
    D --> G[Update Weights]
    E --> G
    F --> G
    G --> B

Effects of a Learning Rate That’s Too High

When the learning rate is too large, weight updates overshoot the minimum of the loss function. This can manifest in several ways:

  • Oscillation: The loss bounces up and down between training steps instead of steadily decreasing.
  • Divergence: In severe cases, the loss increases without bound, and weights can grow so large they produce NaN (Not a Number) values, effectively crashing training.
  • Poor final performance: Even if training doesn’t diverge outright, the optimizer may repeatedly overshoot the true minimum, settling into a worse solution than it otherwise could have found.

Mathematically, consider a simple quadratic loss $\mathcal{L}(\theta) = \frac{1}{2} a \theta^2$. The gradient descent update becomes:

$$ \theta_{t+1} = \theta_t – \eta a \theta_t = (1 – \eta a)\theta_t $$

For convergence, we need $|1 – \eta a| < 1$, which means $\eta$ must satisfy $0 < \eta < \frac{2}{a}$. Exceed this bound, and the sequence of $\theta_t$ values diverges rather than converging to zero.

Effects of a Learning Rate That’s Too Low

A learning rate that’s too small leads to different, but equally problematic, issues:

  • Painfully slow convergence: The model may require an impractically large number of epochs to reach a good solution, wasting compute and time.
  • Getting stuck in poor local minima or saddle points: Small steps make it harder for the optimizer to escape flat regions of the loss surface, since the gradient magnitude in those regions is already small, and multiplying by a tiny learning rate makes updates nearly negligible.
  • Premature convergence appearance: Training might look like it’s “converged” simply because progress has become so slow it’s imperceptible over a normal training budget, when in fact a larger learning rate (or a warm restart) could have found a substantially better solution.

Finding the Right Learning Rate

Learning Rate Range Test

A widely used technique, popularized by Leslie Smith, involves training the model for a few iterations while exponentially increasing the learning rate from a very small value to a very large one, and plotting loss against learning rate. The ideal learning rate is typically found just before the point where loss starts increasing sharply.

import torch
import matplotlib.pyplot as plt

def lr_range_test(model, train_loader, optimizer, criterion, start_lr=1e-7, end_lr=10, num_iters=100):
    lrs, losses = [], []
    lr_mult = (end_lr / start_lr) ** (1 / num_iters)
    lr = start_lr

    for i, (xb, yb) in enumerate(train_loader):
        if i >= num_iters:
            break
        for g in optimizer.param_groups:
            g['lr'] = lr

        optimizer.zero_grad()
        loss = criterion(model(xb), yb)
        loss.backward()
        optimizer.step()

        lrs.append(lr)
        losses.append(loss.item())
        lr *= lr_mult

    plt.plot(lrs, losses)
    plt.xscale('log')
    plt.xlabel('Learning Rate')
    plt.ylabel('Loss')
    plt.title('Learning Rate Range Test')
    plt.show()

Learning Rate Schedules

Rather than using a single fixed learning rate throughout training, most modern deep learning pipelines use a learning rate schedule that adjusts $\eta$ over time.

Step Decay

The learning rate is reduced by a fixed factor every set number of epochs:

$$ \eta_t = \eta_0 \cdot \gamma^{\lfloor t / s \rfloor} $$

where $\gamma$ is the decay factor and $s$ is the step size (number of epochs between decays).

Exponential Decay

$$ \eta_t = \eta_0 \cdot e^{-kt} $$

Cosine Annealing

$$ \eta_t = \eta_{\min} + \frac{1}{2}(\eta_{\max} – \eta_{\min})\left(1 + \cos\left(\frac{t\pi}{T}\right)\right) $$

This smoothly decreases the learning rate following a cosine curve, often producing better final performance than step decay in practice.

Warmup

Many modern architectures, especially transformers, benefit from a “warmup” phase where the learning rate starts near zero and increases linearly for the first several hundred or thousand steps before decaying. This helps stabilize training early on, when weight initialization and gradient statistics are least reliable.

import torch.optim as optim

model_params = model.parameters()
optimizer = optim.Adam(model_params, lr=1e-3)

scheduler = optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=50, eta_min=1e-6)

for epoch in range(50):
    train_one_epoch(model, train_loader, optimizer)
    scheduler.step()
    print(f"Epoch {epoch}, LR: {scheduler.get_last_lr()}")

Adaptive Learning Rate Optimizers

Instead of manually crafting schedules, adaptive optimizers adjust the effective learning rate for each parameter individually based on historical gradient information.

Adam

Adam combines momentum with per-parameter adaptive learning rates:

$$ m_t = \beta_1 m_{t-1} + (1-\beta_1) g_t, \quad v_t = \beta_2 v_{t-1} + (1-\beta_2) g_t^2 $$ $$ \hat{m}_t = \frac{m_t}{1-\beta_1^t}, \quad \hat{v}t = \frac{v_t}{1-\beta_2^t} $$ $$ \theta_t = \theta{t-1} – \eta \frac{\hat{m}_t}{\sqrt{\hat{v}_t}+\epsilon} $$

RMSprop

RMSprop divides the learning rate by an exponentially decaying average of squared gradients, helping stabilize updates in the presence of noisy or sparse gradients.

Comparison Table: Learning Rate Behaviors

Learning RateConvergence SpeedRisk of DivergenceFinal Model QualityTypical Fix
Too highFast initially, then unstableHighPoor or NaN lossReduce LR, use gradient clipping
Too lowVery slowLowMay be stuck in poor minimaIncrease LR, use warmup/adaptive optimizer
Well-tunedEfficientLowGoodMaintain with schedule/monitoring
Adaptive (Adam, etc.)Generally fast and stableLow-moderateGood, but can generalize slightly worse than well-tuned SGDTune betas, consider SGD for final fine-tuning

Advantages of Careful Learning Rate Tuning

  • Faster convergence means less compute cost and faster iteration cycles during development.
  • Better final model performance, since a well-tuned learning rate helps the optimizer find flatter, more generalizable minima.
  • More stable training runs, reducing wasted experiments due to divergence or NaN losses.

Disadvantages and Challenges

  • Manual learning rate tuning is time-consuming and requires multiple experimental runs.
  • Adaptive optimizers, while convenient, sometimes converge to solutions that generalize slightly worse than carefully tuned SGD with momentum, especially in computer vision tasks.
  • Learning rate schedules add additional hyperparameters (decay rate, step size, warmup length) that themselves require tuning.

Real-World Use Cases

  • Large language model pretraining typically uses a warmup phase followed by cosine or linear decay, with peak learning rates carefully tuned based on batch size and model size (following scaling law relationships).
  • Fine-tuning pretrained models generally uses a much smaller learning rate than training from scratch, since large updates risk destroying the useful features already learned during pretraining.
  • Reinforcement learning often requires more conservative learning rates due to the higher variance and non-stationarity of the training signal compared to supervised learning.

Best Practices

  • Always run a learning rate range test before committing to a value for a new architecture or dataset.
  • Use a warmup period for transformer-based architectures or very deep networks.
  • Pair a learning rate schedule with an adaptive optimizer like Adam for most modern deep learning workflows, unless there’s a specific reason to use plain SGD with momentum (e.g., certain vision tasks where SGD is known to generalize better).
  • Use gradient clipping alongside learning rate tuning to guard against occasional large gradient spikes, especially in recurrent architectures.
  • Log learning rate alongside loss curves during training so you can visually correlate learning rate changes with training dynamics.

Summary

The learning rate governs the step size of weight updates during neural network training and is arguably the most consequential hyperparameter to get right. Too high a learning rate causes oscillation or divergence; too low a learning rate causes painfully slow convergence and susceptibility to poor local minima. Modern practice combines careful initial tuning (via techniques like the learning rate range test), learning rate schedules (step decay, cosine annealing, warmup), and adaptive optimizers (Adam, RMSprop) to navigate the loss landscape efficiently and land on high-quality, generalizable solutions.

References

  • Smith, L. N. (2017). “Cyclical Learning Rates for Training Neural Networks.” https://arxiv.org/abs/1506.01186
  • Kingma, D. P., & Ba, J. (2015). “Adam: A Method for Stochastic Optimization.” https://arxiv.org/abs/1412.6980
  • Goodfellow, I., Bengio, Y., & Courville, A. Deep Learning. MIT Press. https://www.deeplearningbook.org/
  • PyTorch Official Documentation on Learning Rate Schedulers. https://pytorch.org/docs/stable/optim.html
Total
1
Shares

Leave a Reply

Previous Post
What are hyper-parameters in the context of neural networks

What Are Hyperparameters in the Context of Neural Networks?

Next Post
What is over-fitting in neural networks

Overfitting in Neural Networks: What It Is and Why It Happens

Related Posts