Library · CC BY-SA 4.0

Alice's Adventures in aDifferentiable Wonderland

Alice's Adventures in a Differentiable Wonderland, Volume I: A Tour of the Land

Cover illustration of the book

Choose your version

The same text, told at every level, in every language and look shown here. Pick, then listen or download.

Listen and watch

The same player the product gives for your own book: the voice, the drawings as they are drawn, the text.

A modern textbook on how neural networks really work, from tensors and gradients to transformers. Chapter 6 shows how a program finds its own gradients: automatic differentiation, the reverse walk behind every trained model.

This is a sample: 1 of 13 chapters.

From the lectures

A box with three inputs, six weights and two outputs; beside it a grid of 2 by 3 cells for the input Jacobian and a grid of 2 by 6 cells for the weight Jacobian.
A Chain of Buttons

The Two Tables of a Primitive

The book assumes only one thing about each primitive: that we know its local rates, collected in two tables called Jacobians. The input Jacobian says how each output number moves when each input number is nudged, so it has one row per output and one column per input.

The function a·sin x + b·x·sin x and its derivative a·cos x + b·x·cos x + b·sin x, with the two sines and the two cosines highlighted as repeated work.
Three Ways to Find a Slope

A Formula and Its Repeats

The second way is the one you learned at school. Take a small function: a times the sine of a number, plus b times the number times its sine.

A long product drawn as shapes: a thin row of ones, then three square tables, then one narrow table; a red arrow from the right end shows table-times-table products, a green arrow from the left end shows a row moving through the tables and staying a row.
Walking the Chain Backwards

Which End to Start From

The book writes out the rate of the final score with respect to the weights of one step, somewhere in the middle of the chain. It is a long product. First comes a row of ones, which stands for the final sum: every number of the last result counts once in the score.

A box with the forward pass entering on the left and leaving on the right, and two arrows going back through it: one gives the weight rates, the other the next adjoint; below, rows with a single one in turn rebuild a full table row by row.
Never Build the Table

A Primitive With Two Backward Rules

So a backward step is just two calls. Call the weight vector-Jacobian product with the adjoint, and out come the rates of the score with respect to that step's weights. Call the input vector-Jacobian product with the same adjoint, and out comes the new adjoint, ready to be carried one step back.

A machine labelled grad takes in the function sum of squares and gives out a new function; fed 1, 2, 3, the new function returns 2, 4, 6, while the old one returns 14; below, an object with weights inside is opened into a function that takes input and weights side by side.
Notes Left Along the Way

A Function That Makes Functions

In a functional library such as JAX, everything is a function, and so is differentiation. A vector-Jacobian product becomes a function that makes functions.

The ReLU with the line of slope one half through the corner: at input 2 the line is at 1 below the ReLU's 2, at input −2 it is at −1 below the ReLU's 0; the line of slope 1.5 reaches 3 at input 2, above the ReLU.
A Ruler at the Corner

Checking a Subgradient

The more careful answer uses the fan you just drew. For a function that curves upwards, a convex function, a subgradient at a point is the slope of a line through that point which stays below the whole function everywhere.

How it was made

Examples for: a curious adult with school maths who uses AI apps every day; add one modern instance per idea, such as how a chat assistant or a phone's photo app is trained

The source

The lectures retell the English text of arXiv 2404.17625 (version 3, 2025) by Simone Scardapane, published under an open licence that allows retelling and translation. The retelling, the drawings and the voice are made by AI and checked against the book by a second model. How AI is used.

The lectures adapt the original and are released under the same licence, free to share and adapt with credit to the author and a link to this page: CC BY-SA 4.0

Your own hard book, the same way

Upload a textbook or any difficult book. The first five minutes are free.

Upload a book