Introduction
What these tutorials are about, what you'll learn, and what you need to get started.
Deep learning has a reputation for being either impenetrably mathematical or frustratingly hand-wavy. These tutorials aim for neither.
The goal is simple: understand what's actually happening. Not just how to call loss.backward(), but what the framework is doing when you do. What a gradient is, how it flows, why the code is shaped the way it is.
For that, the code is written in PyTorch. Wherever it helps, we also rebuild its building blocks by hand (a recurrent cell, an attention head, a transformer block) so that nothing stays a black box. Every idea is first explained with the math, then shown in a few lines of code.
The Plan
These tutorials have one concrete endpoint: re-implement GPT-2 from scratch, understanding every single line. Not as a magic trick, but as a logical consequence of everything that came before.
To get there, we build up from the very bottom:
Each chapter is a self-contained step. No hand-waving, no "trust the framework". If something happens, we explain why.
What You'll Learn
Math Foundations — Vectors, matrices, derivatives, gradients. The handful of concepts that show up everywhere in deep learning, explained geometrically before algebraically.
Autograd — How automatic differentiation works under the hood. The chain rule, computation graphs, and backpropagation, the engine that powers every modern DL framework.
Training — Loss functions, gradient descent, optimizers (SGD, Momentum, Adam), and the training loop. How a network actually learns from data.
Building Blocks — Activation functions, linear layers, regularization. The primitives every architecture is made of.
Convolutional Networks — How CNNs detect features in images, how convolution is implemented efficiently, and how to train a digit classifier on MNIST.
Recurrent Networks — RNNs, LSTMs, GRUs. What it means for a network to have memory, and why sequential architectures struggle at scale.
Transformers — Embeddings, positional encoding, attention, multi-head attention, transformer blocks. The architecture that replaced RNNs for nearly every sequence task.
GPT-2 from Scratch — Assembling every piece into a working autoregressive language model, in PyTorch, line by line.
No tutorial requires you to memorize a formula. But by the end, you should be able to read a reference GPT-2 implementation and understand every line.
What You Need
Basic Python. Some intuition for vectors and matrices (nothing formal). Curiosity about how things work. That's it.
Calculus is not a prerequisite ! We introduce derivatives from scratch in the Math Foundations chapter, starting from the geometric intuition.