Learn Before
Code

Explicit Learning Rate Adjustment Implementation

A basic learning rate adjustment can be performed explicitly at each step by modifying the optimizer's parameter groups directly. The following Python code demonstrates how to set a new learning rate manually in a PyTorch optimizer:

lr = 0.1 trainer.param_groups[0]["lr"] = lr print(f'learning rate is now {trainer.param_groups[0]["lr"]:.2f}')

0

1

Updated 2026-05-18

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L