Log inStart free
LESSON 2.12 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Automatic differentiation

Watch automatic differentiation push exact derivatives through a graph of simple steps.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 2.12 · AUTODIFF BAY2 INPUTS · 5 STEPS · 1 OUTPUT
01
Stage 1 of 6 · Build the graph
A computational graph splits y into 5 simple operations, from left to right.
Explain it simply

A computer doesn't see the formula as one piece. It splits it into small steps, like lines in a recipe. Each box is one step: ln, times, sin, plus or minus. The lines show which box feeds which. This map is called a computational graph.

A graph with inputs x₁ and x₂, operation nodes a, b, c, d and y, and 8 edges.

input and node valueslocal derivative on an edgecarried derivative, Jacobianoutput valuegraph structure
computational graphevaluation ordery = ln x₁ + x₁·x₂ − sin x₂ at x₁ = 2, x₂ = 5x₁x₂a = ln x₁b = x₁·x₂c = sin x₂d = a + by = d − c1 x₁ input2 x₂ input3 a = ln x₁4 b = x₁·x₂5 c = sin x₂6 d = a + b7 y = d − ceach node reads onlynodes above itcomputational graphevaluation ordery = ln x₁ + x₁·x₂ − sin x₂ at x₁ = 2, x₂ = 5x₁x₂a = ln x₁b = x₁·x₂c = sin x₂d = a + by = d − c1 x₁ input2 x₂ input3 a = ln x₁4 b = x₁·x₂5 c = sin x₂6 d = a + b7 y = d − ceach node reads onlynodes above it
Toy: 2 small graphs of 4 or 5 operations · numbers to 2 decimals
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
vj=ϕj(the nodes that feed vj)\sy{v}{data}{v_j} = \phi_j(\text{the nodes that feed } v_j)
a=ln⁡x1, b=x1x2, c=sin⁡x2, d=a+b, y=d−ca = \ln x_1,\ b = x_1 x_2,\ c = \sin x_2,\ d = a + b,\ y = d - c

Each node applies one simple operation to the nodes that feed it.

Common mix-ups

MYTHAutomatic differentiation estimates slopes with tiny input steps.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01How many reverse passes give both ∂y/∂x₁ and ∂y/∂x₂?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.