Learn
Eleven lessons, all of them running
Every block is written twice — a JavaScript tab and a Python tab, the same work on each. Lesson 0 opens in Python; the others open in JavaScript and switch with one click. The Playground takes both as well.
Every code block on these pages executes in this tab, on your GPU, and you can edit it before you run it. Nothing is installed and nothing is uploaded. Start at the top if borch is new to you; each lesson takes a few minutes.
0 · Fix the bug
Python, nothing installed. Two loops that do not learn; fix them and the page says so — start here.
1 · Tensors
Shapes, dtypes, operations, and why reading a value is awaited.
2 · Autograd
backward(), accumulation, noGrad, and how to tell a gradient actually flowed.
3 · Modules
Linear, Sequential, writing your own layer, and the losses.
4 · Training
The loop, optimizers, schedulers — and the scope that keeps the device from filling.
5 · Convolution
Conv2d, pooling, flatten, and counting what the GPU was asked to do.
6 · Saving
safetensors checkpoints, and the same kernels called from Python.
7 · Data
Datasets, batching, shuffling, a held-out split, and image transforms.
8 · Debugging
What to ask the device when the numbers are wrong and nothing threw.
9 · Residual
Skip connections, a BasicBlock, and measuring the gradient they carry.
10 · Transformer
Patches as tokens, attention, a class token — and where borch.ts is narrower than torch.
What you need
- A browser with WebGPU. If yours does not have it, the pages say so rather than quietly falling back to something slower.
- Nothing else. No install, no account, no server.
How these pages are kept honest
Examples that are never run rot, and the first person to find out is a reader. Everything here executes against the same library the test suite runs against — when a name changes, these pages break where you can see it.
If you would rather build something than read about it, Tutorials takes one problem to the end instead — the same material arrives, in the order a project needs it rather than the order the ideas depend on each other.
The wider claim this project makes is narrow and measured: introductory tutorial code produces the same values with only the import changed. The numbers behind that are on the home page, and what is deliberately absent is listed there too.