The chain rule computes how an outer result changes when an inner quantity changes. For a loss built from a model, multiply the loss derivative with respect to the model output by the model derivative with respect to each parameter. section 5.4.2
In learning, this turns a change in model parameters into a change in loss. The resulting derivatives form a gradient, which indicates how to adjust weights and bias to reduce the error. section 5.2 section 5.4.2
For a linear model followed by a mean-squared-error loss, the calculation proceeds as follows:
- Differentiate the loss with respect to each prediction; averaging contributes a division by the number of predictions. section 5.4.2
Manual gradient for a model and loss
The implementation multiplies derivatives directly: dloss_dw = dloss_dtp * dmodel_dw(t_u, w, b) and dloss_db = dloss_dtp * dmodel_db(t_u, w, b). This is a simple backward pass through the loss and model. section 5.5
Figure 5.6 Comparing numerical vs. analytical gradient calculation. The numerical approach (arrow through points) estimates the gradient using finite differences between discrete points, while the analytical approach (arrow along the curves) calculates the exact gradient at a specific point.
Compare numerical gradient estimates between discrete points with analytical derivatives evaluated at a specific point. section 5.4.2



