Example

Concise SGD Training Example on Airfoil Dataset

To validate the concise training harness, train_concise_ch11 is invoked with torch.optim.SGD as the optimizer, a learning rate of 0.010.01, and a minibatch size of 1010 on the Airfoil Self-Noise dataset. The training reproduces the same convergence behavior observed with the from-scratch implementation, reaching a final loss of approximately 0.2430.243 in about 0.0960.096 seconds per epoch. This confirms that the high-level-API version and the manually coded version yield identical optimization trajectories.

python data_iter, _ = get_data_ch11(10) trainer = torch.optim.SGD train_concise_ch11(trainer, {'lr': 0.01}, data_iter)

Output:

loss: 0.243, 0.096 sec/epoch

Image 0

0

1

Updated 2026-05-15

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L