Skip to the workspace
Pebellslearn by building
Calculus  ›  Lesson

Derivatives and Partial Derivatives

Derivatives, Partial Derivatives 14 minA derivative measures how fast an output changes for a tiny change in one input, and a partial derivative does the same while holding every other input fixed.

machine learning / Derivatives and Partial Derivatives

Explore each scene at your own pace.

01 · The rule

The rule

Derivatives and Partial Derivatives

Training a model is a long series of small questions: "If I nudge this weight up a little, does the error go up or down, and by how much?" The derivative answers that question. With several weights, the partial derivative answers it for one weight at a time.

The rule

Derivative: output change per tiny input change. Partial: freeze every other input.

A derivative is the slope of a function at a point. Take f(w)=w2f(w) = w^2. Its derivative is f′(w)=2wf'(w) = 2w, so at w=3w = 3 the slope is 6. That means a tiny nudge in ww changes ff about six times as much: f(3)=9f(3) = 9 and f(3.01)=9.0601f(3.01) = 9.0601, a rise of about 6×0.016 \times 0.01.

The rules you need most:

  • Power rule: the derivative of wnw^n is nwn−1n w^{n-1}. So 5w35w^3 gives 15w215w^2.
  • Constants vanish: a number on its own has slope 0.
  • Constant multiples stay: the derivative of 3w3w is 3.
  • Sums split: differentiate each term separately.

The sign matters as much as the size. A positive slope means increasing ww increases ff. A negative slope means increasing ww decreases ff. To reduce an error, move the weight against the slope.

A model usually has many weights. A partial derivative measures the slope along one of them while every other weight is treated as a fixed number. For f(w,b)=w2+3wbf(w, b) = w^2 + 3wb:

  • ∂f/∂w=2w+3b\partial f / \partial w = 2w + 3b, because bb is frozen, so 3wb3wb is just 3b3b times ww.
  • ∂f/∂b=3w\partial f / \partial b = 3w, because w2w^2 has no bb in it and vanishes.

At (w,b)=(1,2)(w, b) = (1, 2) these are 8 and 3.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.