Code

SyntheticRegressionData Class

The SyntheticRegressionData class encapsulates the procedural generation of synthetic datasets for linear regression models. Inheriting from a base DataModule (such as d2l.DataModule), its init constructor takes the true parameters w and b, alongside hyperparameters like noise (defaulting to 0.010.01), num_train, num_val, and batch_size. After invoking save_hyperparameters(), it constructs the feature matrix X\mathbf{X} from a normal distribution and computes the label vector y\mathbf{y} using the formula y=Xw+b+ϵ\mathbf{y} = \mathbf{X} \mathbf{w} + b + \boldsymbol{\epsilon}. This structure standardizes the dataset preparation for training and validation.

0

1

Updated 2026-05-02

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L