Библиотека · CC BY-SA 4.0

Приключения Алисы в Странедифференцируемых чудес

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

Иллюстрация к книге

Выберите версию

Один и тот же текст на каждом уровне, на всех языках и во всех оформлениях, что здесь есть. Выберите, потом слушайте или скачивайте.

Слушать и смотреть

Тот же плеер, который продукт даёт для вашей книги: голос, рисунки по мере того, как они рисуются, текст.

Современный учебник о том, как на самом деле устроены нейросети: от тензоров и градиентов до трансформеров. Глава 6 показывает, как программа сама находит свои градиенты: автоматическое дифференцирование, обратный проход, на котором обучается любая модель.

Это пробная часть: 1 из 13 (главы).

Из лекций

Two grids side by side: on the left a 2 by 3 grid labelled input Jacobian, on the right a 2 by 6 grid labelled weight Jacobian, each with its rows marked as outputs.
A Program Made of Small Steps

The Two Jacobians of a Layer

The only thing assumed about each primitive is that we know how to compute its partial derivatives with respect to its two arguments. The first is the input Jacobian, ∂ₓ[f(𝐱, 𝐰)] ∼ (c′, c): how each output moves when each input is nudged.

Two primitive boxes f1 and f2 in a row, then a 2 by 4 grid times a 4 by 3 grid equals a 2 by 3 grid, the shapes labelled 2×4, 4×3 and 2×3.
Three Ways to Get a Derivative

Chain Rule as a Table Product

Now the third way, starting from the chain rule. Take two primitives in a row, 𝐡 = f₁(𝐱), 𝐲 = f₂(𝐡). The chain rule of Jacobians says ∂ₓ𝐲 = ∂_𝐡𝐲 · ∂ₓ𝐡.

The chain 2, times 3, times 5 gives 6 and 30; red arrows then run back from the end carrying 1, 5 and 15, handing out gradients 6 for w2 and 10 for w1.
Turning the Chain Around

Backwards on the Calculator

Take the calculator chain from the last part again: x is 2, multiplied by w₁ equal to 3, then by w₂ equal to 5. Run it forward and write down what you see: 6 after the first step, 30 after the second. Now start backwards with h̃ equal to 1.

A column v holding 1 and minus 1 times a row x holding 1 and 2 makes a 2 by 2 table with rows 1, 2 and minus 1, minus 2, each entry v i times x j.
The Backward Step of a Layer

The Weight VJP Is an Outer Product

The weight VJP turns out to be an outer product, with no rank-3 tensor anywhere: vjp_f,𝐰(𝐯) = 𝐯𝐱ᵀ. An outer product of two vectors is the table whose entry in row i and column j is the i-th entry of the first times the j-th entry of the second.

The S-shaped sigmoid climbing from 0 to 1, and under it its derivative as a low hump that peaks at 0.25 at s equal to 0.
Frameworks, and Why the ReLU Wins

The Sigmoid's Slope Peaks at a Quarter

Now the sigmoid, the S-shaped curve σ(s) that was popular in the past as a soft version of the step function. Its derivative is σ′(s) = σ(s)(1 − σ(s)). In words: the slope is the value times what is left to reach 1.

Three boxes labelled ReLU, ReLU2 and ReLU3 each with an arrow to the value its backward pass returns at zero: 0, 1 and 0.5.
The Corner of the ReLU

Same Function, Three Answers

The full story is trickier. For functions that are not convex, a subgradient need not exist, and one turns to generalizations that relax the definition to a small neighbourhood of x, such as the Clarke subdifferential.

Как это сделано

Примеры для: 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

Источник

Лекции пересказывают с английского оригинала книгу arXiv 2404.17625 (version 3, 2025), автор — Симоне Скардапане; книга вышла под открытой лицензией, которая разрешает пересказ и перевод. Пересказ, рисунки и голос сделаны ИИ и сверены с книгой второй моделью. Как используется ИИ.

Лекции — переработка оригинала и распространяются под той же лицензией: их можно свободно распространять и перерабатывать с указанием автора и ссылкой на эту страницу: CC BY-SA 4.0

Ваша трудная книга — так же

Загрузите учебник или любую сложную книгу. Первые пять минут бесплатно.

Загрузить книгу