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

Four boxes in a row joined by arrows, each with a small knob on top for its weights and a slope tag under it, and at the end a multiplication of the four tags gives the slope of the whole.
A Program That Knows Its Own Slopes

A Chain of Primitives

The book's answer starts by looking at the model as a program. When the program runs, it performs a chain of small, simple operations, one feeding the next; the book calls each one a primitive, and the whole chain, as it actually ran, a computational graph.

A chain of three boxes run left to right; under each box a page appears, and each new box sends update arrows back to every earlier page; a small grid times a grid shows the costly product.
One Number at the End, and the Slow Way Forward

Forward Mode: A Notebook

Now the first road, forward mode. Think of it as walking along the chain in the direction the program runs, carrying a notebook.

A chain of four steps ends in one error dot; a short strip of four cells starts at the error and moves left from step to step, dropping a slope tag under each step.
Walking the Chain Backwards

Carrying One Row Back

The book's key observation is that the chain ends in one number, the total error. So if you start the multiplication from that end, what you carry is never a whole table, only a single row of numbers, and a row times a table is cheap and gives another row.

Left: a big three-dimensional block crossed out next to a flat grid built from a short column and a short row of numbers; right: a row of numbers passing through a ramp-shaped switch, with negative positions set to zero and the others unchanged.
Every Piece Learns to Answer Backwards

Cheap Answers, Two Examples

Two examples show why the answers are so much cheaper than the tables. For the most common piece of a network, multiplying the input by a table of weights, the full table of slopes with respect to the weights would be a huge three-dimensional block of numbers.

Three result boxes in a chain, each with a small tag pointing back to the operation that made it and an empty slope slot; an arrow walks back from the error and fills the slots of two of them, leaving one empty.
How Libraries Do It, and Why the ReLU Won

Results That Remember

Object-style models, the usual way of writing PyTorch, need one more step. One option is to pull the weights out of the model object and call it as a plain function with those weights handed in.

Three boxes, each a different way of writing the ReLU, all fed the input zero, reporting slopes 0, 1 and 0.5; then a small branching graph whose steps are numbered in order before the walk back.
The Corner of the Ramp

Same Function, Different Slopes

The book adds a warning. For curves that bend both ways, subgradients need not exist, and mathematicians use a looser, local version instead.

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