Learn Before
Example
Learning Rate Warmup Schedule Example
A learning rate warmup can be applied to various learning rate schedules, such as a cosine schedule, to stabilize training and improve initial convergence. In deep learning frameworks, this is often configured using a warmup steps parameter. For example, a cosine scheduler can be configured to linearly increase the learning rate for the first 5 steps before applying standard cosine decay. Plotting the learning rate schedule over epochs visually demonstrates this initial linear increase followed by the cooling-down (decay) period.
num_epochs = 20 scheduler = CosineScheduler(num_epochs, warmup_steps=5, base_lr=0.3, final_lr=0.01) d2l.plot(torch.arange(num_epochs), [scheduler(t) for t in range(num_epochs)])
0
1
Updated 2026-06-29
Tags
D2L
Dive into Deep Learning @ D2L