Skip to content
BIASED

Gradients, Jacobians and Hessians

Block 1 of 8~2 min

Partial derivatives

The topic Derivatives and Taylor series gave us the derivative of a function of one variable: the best linear approximation near a point. A model's loss L(θ)L(\theta) depends on all of its parameters at once, and a network has millions of them. We need derivatives in many variables.

The simplest idea is to freeze every variable but one and differentiate along that one. This is the partial derivative. For f(x1,…,xn)f(x_1, \dots, x_n) and the ii-th basis vector eie_i,

∂f∂xi(x)=lim⁡t→0f(x+tei)−f(x)t.\frac{\partial f}{\partial x_i}(x) = \lim_{t \to 0} \frac{f(x + t e_i) - f(x)}{t}.

The other coordinates act as constants, so every rule from one-variable calculus applies unchanged.

The running example of this topic is a small loss surface, a bowl with two parameters:

q(x)=x12+x1x2+2x22=x⊤Ax,A=(10.50.52).q(x) = x_1^2 + x_1 x_2 + 2x_2^2 = x^\top A x, \qquad A = \begin{pmatrix} 1 & 0.5 \\ 0.5 & 2 \end{pmatrix}.

It is a quadratic form with a positive definite AA, as in the topic Symmetric matrices and quadratic forms. Holding x2x_2 fixed and then x1x_1 fixed gives

∂q∂x1=2x1+x2,∂q∂x2=x1+4x2.\frac{\partial q}{\partial x_1} = 2x_1 + x_2, \qquad \frac{\partial q}{\partial x_2} = x_1 + 4x_2.

In a real loss the roles are worth keeping straight. For a linear model with one feature and the squared error on one example, L(w,b)=(wx+b−y)2L(w, b) = (wx + b - y)^2, the data xx and yy are constants. The parameters ww and bb are the variables.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • Gradient vs finite differencesoptional

    Match analytic ∇f to central differences on R^3; tol 1e-5.

    ~20 min · easier on a computer · The matching course topic has been read.

    Self-check in the notebook — not part of mastery or the certificate.