Gradient, Jacobian and Hessian
A real model has many weights and makes many predictions. Writing one partial derivative at a time quickly becomes a mess. Three named collections keep it tidy, and each one appears in ML papers and error messages all the time.
The rule
Gradient: slopes of one output. Jacobian: slopes of many outputs. Hessian: slopes of slopes.
Give the rent model a bias: prediction for flat B, whose rent is 22. The loss is . Call the error .
Gradient: all first partials of a single number, stacked in a vector. By the chain rule,
At : , so . The gradient points in the direction of steepest increase. Gradient descent steps the other way: new weights old weights learning rate gradient. With learning rate 0.01, becomes and becomes . The error shrinks to and the loss drops from 9 to about 0.61.
Jacobian: when there are several outputs, stack each output's gradient as a row. Predictions for flat A () and flat B () are and , so
Rows are outputs, columns are inputs.
Hessian: the partials of the partials of one number, showing how the slope itself changes (the curvature). For , the gradient is , and differentiating again gives
It is symmetric, because the order of mixed partials does not matter for smooth functions.