Torch Canvas
Diagram ⇄ PyTorch
A visual editor for neural networks that writes PyTorch as you draw, and turns PyTorch modules back into diagrams. It runs in the browser with nothing to install.
Start from a real model
Each one opens in the editor, ready to explore, change, and export. 22 networks and 26 building blocks, straight from the project's example library. A few favorites first, then everything by category.
Browse all 48 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
No examples match that search.
What it does
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: diagram → code → 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: 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:
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 (b95b148) on October 23, 2026.