Learn Before
Example
Linear Regression Training Execution Example
To execute the training loop for a model from scratch, we instantiate the required components and begin the optimization process. For example, we initialize a linear regression model, LinearRegressionScratch, specifying hyperparameters such as the learning rate, lr=0.03. We then create the dataset using a class like SyntheticRegressionData, passing in ground truth parameter values. Next, an object-oriented Trainer is instantiated with settings such as max_epochs=3. Finally, training is executed by calling trainer.fit(model, data), which orchestrates the iterations over the dataset to optimize the model's parameters.
0
1
Updated 2026-05-03
Tags
D2L
Dive into Deep Learning @ D2L