Torch Canvas

See, build and understand neural networks

Torch Canvas turns neural networks into diagrams you can read, edit and run. Draw a model and the PyTorch code writes itself, or paste PyTorch and watch it become a diagram. Use it to teach, to make figures for papers, and to understand what every component does. It runs in the browser with nothing to install.

Open Torch Canvas Source on GitHub

What it's for

Teach architectures

Show how a network is put together, from a 10-layer MLP to Llama 2, with tensor shapes on every connection. Each example has its own link, so a slide can open the exact model.

Make figures for papers

Export any diagram as a clean SVG for papers and slides, drawn the way it looks on screen, with size labels placed where they read best.

Code visually

Build a model by drawing it. Every edit updates clean, runnable PyTorch, and pasting a module turns it back into a diagram you can keep editing.

Understand the components

Select any piece to see what it computes, how it changes the shape and what it adds in parameters. A variance plot shows how the signal grows or shrinks through the network before training.

Explore real models

Every example opens as a diagram you can read, change and export, with its PyTorch code beside it. There are 25 networks and 27 building blocks from the project's example library. A few favorites come first, then everything by category.

Browse all 52 examples

MLPs and residual basics

Small fully connected networks for seeing how depth, activations, normalization and residuals behave.

Building blocks

Convolutional networks

Image classification, detection and segmentation built from convolutions.

Building blocks

Recurrent and state-space models

Networks that carry a state through a sequence, from the Elman RNN to Mamba.

Building blocks

Transformers and language models

The original encoder-decoder Transformer and the language models built on it.

Building blocks

Vision transformers and multimodal

Transformers that read images, alone or together with text.

Building blocks

Generative and self-supervised

Models that learn without labels, by reconstructing their input or predicting hidden parts of it.

Building blocks

More examples

Building blocks

Features

Diagram ⇄ code, both ways

Draw a network and the PyTorch code updates as you go. Paste an nn.Module (or a torch.fx export) and it becomes a diagram. Every example round-trips from diagram to code and back to the same diagram.

Shapes and parameters, live

Tensor sizes are worked out symbolically and shown on every connection, with a running parameter count. A size that doesn't fit, like a head count that doesn't divide d, turns red.

See variance before you train

Plot how activation and gradient variance change through the network right after initialization, worked out analytically. Change an init and replot to compare.

Reusable blocks

Define a block once (a transformer layer, a SwiGLU MLP) and repeat it. Edit it anywhere and every network that uses it updates.

Ready-to-run training scripts

Add a loss (cross-entropy with next-token or masked targets, BCE, MSE, L1, Huber), then export model.py and a complete train.py with your optimizer, schedule, precision, and checkpointing.

Real architectures, checked

GPT-2, BERT, Llama 2 and Qwen2.5-VL match their reference implementations, with the same parameter counts at full size, and the same outputs with the weights copied across (GPT-2 against nanoGPT, the others against Hugging Face transformers).

For teaching

Every example has its own link, so a slide or course page can open exactly the model being discussed. For example, https://www.jessetnroberts.com/torch-canvas/?open=gpt2 opens GPT-2. It's used in AI 4200 / 5200 Deep Learning.

Example list synced from JesseTNRoberts/torch-canvas (06caf29) on November 4, 2026.