05-training-loop uses every row for every update, which is clear but becomes expensive as datasets grow. Mini-batches let training update from small groups while still eventually seeing the whole dataset. The practical challenge is preserving feature-target pairing, handling the final short group, and making shuffled training reproducible when a seed is supplied.
Implement train_linear_regression_production. Use the earlier MSE gradient and gradient-descent step for one shuffled batch at a time; Theory explains the epoch-level ordering and the single long-lived random generator.
input has shape (n_samples, in_features) and target has shape (n_samples,).weight with shape (1, in_features) and bias with shape (1,).(n_samples, 1) once before training.batch_size.np.random.default_rng(seed) once before the epoch loop.None seed and arguments must produce bit-identical parameters; seed=None must not force a fixed order.input and target; reuse mse_gradient and gd_step.Open one at a time. Each gives away a little more than the last.
Shuffle row indices, not features and targets separately. One index array preserves their pairing.
range(0, n_samples, batch_size) naturally visits the start of a final short batch.
Create one generator before training. In each epoch, call its permutation(n_samples), then use order[start : start + batch_size] to select both batch arrays.
No results yet
Run your code to check it against the examples, or submit to run every test.