Tag: Optim

  • ML0008 Learning Rate Selection

    What are the best practices for selecting an optimal learning rate?

    A three-panel question card showing a new training config with the learning rate left blank, a compute budget that allows only four full runs, and a published learning rate taken from a different batch size and dataset.

    The Problem: You must fill in the learning rate for a new training job. Each full run takes 12 GPU-hours, so the budget covers only four runs, and the only reference value comes from a paper that used a different batch size and dataset. How do you choose the learning rate in a principled way?

    Answer

    Selecting an appropriate learning rate is one of the most important choices in training a neural network: it largely determines how quickly and how well the model learns. Four practices cover most situations. First, grid or random search over a range (e.g., 0.0001, 0.001, 0.01) while watching training performance, to narrow down an effective value. Second, use adaptive optimizers such as Adam, RMSProp, or Adagrad, which adjust the effective rate per parameter from gradient history and need less manual tuning. Third, apply learning rate schedules (step decay, exponential decay, or cosine annealing) that shrink the rate as training approaches convergence. Fourth, monitor the training loss: if it stops decreasing or oscillates, adjust the rate. Too high a rate overshoots the optimum and oscillates or diverges; too low a rate converges slowly or stalls; the right rate converges efficiently to a good solution.

    (1) Why It Matters: The learning rate scales every update step; it is the single hyperparameter that most often decides whether training works at all.
    (2) Four Practices: Search a range, prefer adaptive optimizers, decay the rate over time, and watch the loss curve.
    (3) Diagnose From The Curve: Oscillating or rising loss means too high; an almost flat, slowly creeping loss means too low.

    Training loss for too low, good, and too high learning rates

    Figure 1: Reading the loss curve: too low creeps down slowly, a good rate drops fast and plateaus, too high oscillates and can diverge.

    Mathematical Formulation:
    \theta_{t+1} = \theta_t - \eta_t \, \nabla_\theta \mathcal{L}(\theta_t)
    \eta_t = \eta_0 \, \gamma^{\lfloor t / s \rfloor} \quad \text{(step decay)}

    Where:

    • \theta_t denotes the model parameters at step t.
    • \eta_t is the learning rate at step t, now time-dependent because of the schedule.
    • \eta_0 is the initial learning rate, \gamma \in (0,1) is the decay factor, and s is the number of steps between decays.
    • \nabla_\theta \mathcal{L}(\theta_t) is the gradient of the training loss \mathcal{L}, scaled by \eta_t at every update.
    Step, exponential, and cosine learning rate decay schedules

    Figure 2: Three standard schedules. All shrink \eta_t over training so the model takes large steps early and fine steps near convergence.


    Login to view more content
  • ML0001 Loss Curve Plot

    The following training loss curves were produced under four different experiment settings. Which curve most likely corresponds to a correct training setup, and what does each of the remaining curves indicate?

    Four training loss curve shapes: decreasing, increasing, flat, and oscillating

    The Problem: Training loss curves recorded under four experiment settings ((1)–(4)). Only one reflects healthy training.

    Answer

    Curve (1) most likely corresponds to a correct training setup: the loss drops quickly in early epochs and then flattens as the model converges, which is the signature of steady learning with a well-tuned learning rate. Curve (2), where the loss increases monotonically, indicates divergence: typically a learning rate far too large or a sign error in the loss or gradient. Curve (3) stays flat, meaning the weights are barely updating: a near-zero learning rate, broken gradient flow, or frozen parameters. Curve (4) oscillates sharply, the classic symptom of a learning rate too high for stable descent, so the optimizer keeps overshooting the minimum.

    (1) Healthy Curve: A smooth, rapid decrease that levels off toward a floor, showing that gradients flow and the step size is well tuned.
    (2) Failure Signatures: Rising loss means divergence, flat loss means no learning, and violent oscillation means unstable steps.
    (3) First Knobs To Turn: Check the learning rate first, then gradient flow (vanishing or exploding), then the loss wiring itself.

    Mathematical Formulation:
    \theta_{t+1} = \theta_t - \eta \, \nabla_\theta \mathcal{L}(\theta_t)
    \mathcal{L}_t \to \mathcal{L}_{\min} \quad \text{as} \quad t \to T \text{ for a healthy run}

    Where:

    • \theta_t denotes the model parameters at epoch t, and T is the final epoch.
    • \eta is the learning rate, the single hyperparameter behind curves (2) and (4) in most real failures.
    • \nabla_\theta \mathcal{L}(\theta_t) is the gradient of the training loss \mathcal{L}; if it vanishes or is disconnected, the curve goes flat as in (3).
    • \mathcal{L}_{\min} is the approximate floor the loss converges to, above zero in practice because of label noise and mini-batch variance.

    Login to view more content