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. The first three chapters lay the ground: what the book is about, the linear algebra and calculus a network runs on, gradient descent, and what a dataset and a loss function are.

This is a sample: 3 of 13 chapters.

From the lectures

Three blocks for the parts of the book with their chapters, followed by a website and lab notebooks.
About this book

The Book's Three Parts

The third part of the book, Down the Rabbit Hole, continues our exploration of differentiable models by considering alternative designs for sets, most importantly attention layers and transformer models in Chapters 10 and 11, graphs in Chapter 12, and finally recurrent layers for temporal sequences in Chapter 13.

Two arrows from the origin and their sum as the diagonal of a parallelogram; the length of an arrow is its norm.
License, and the mathematical preliminaries

Adding Vectors, Measuring Length

Vectors possess their own algebra, which we call a vector space, in the sense that any two vectors 𝐱 and 𝐲 of the same shape can be linearly combined, 𝐳 = a𝐱 + b𝐲, to provide a third vector, with zᵢ = axᵢ + byᵢ.

The parabola f(x) = x² − 1.5x with two tangent lines, one falling where the slope is negative and one rising where it is positive; then the three rules of derivatives listed.
Einstein's notation, and derivatives

Slopes of x² − 1.5x

Geometrically, the derivative can be understood as the slope of the tangent passing through a point, or equivalently as the best first-order approximation of the function itself at that point, as shown in Figure F.2.1.

A convex bowl with a straight chord between two points above it; the curve stays below the chord. Beside it a bumpy curve where a chord crosses it.
Convergence of gradient descent

Convex: Below Every Chord

We can generalize this idea with the concept of convexity of a function. There are many possible definitions of convexity; we choose the one below for simplicity of exposition.

A large grid of grey cells for a model's parameters with only a thin strip of extra cells highlighted; below, a dataset where only some rows have labels.
Variants of supervised learning

Tuning Few Parameters

Fine-tuning is made especially easy by the presence of large open-source repositories online.

The MAP formula split into a likelihood term and a regularizer term; with a flat prior the regularizer becomes a constant and only maximum likelihood remains.
Maximum likelihood, and Bayesian learning

MAP: Likelihood Plus Regularizer

The overall beauty of this setup is marred by the fact that the posterior is in general impossible to compute in closed form, except for very specific choices of prior and likelihood. Lacking this, one is forced to approximate solutions, either by Markov chain Monte Carlo or by variational inference.

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