01 / THE QUESTION
What is the best tool to visualize a PyTorch model?
It depends on where the model is and what you want to see. The tools fall into four groups:
- File viewers read a saved model. Netron opens ONNX, TensorFlow Lite, Core ML, TorchScript,
torch.exportfiles and many other formats. Model Explorer opens TFLite, TF, TFJS, MLIR and PyTorchExportedProgramfiles. - Forward-pass tracers run your
nn.Modulewith an example input and draw what happened. tensorViz, torchview and torchvista work this way, as does TensorBoard’sadd_graph, throughtorch.jit.trace. - Autograd graph drawing: torchviz draws the backward graph behind an output tensor.
- Summaries: torchinfo prints a table of layers, shapes and parameter counts.
tensorViz differs from the other tracers in where it runs. It is a VS Code, Cursor and VSCodium extension, and a coding-agent plugin. The graph opens beside your Python, and you can follow a layer back to its source. Without running anything, Inspect source only shows a preview read from the code. That preview has no measured shapes.
02 / SIDE BY SIDE
How do the PyTorch visualization tools compare?
Release dates are from PyPI, the VS Code Marketplace or GitHub releases. Commit dates are the latest commit on the default branch on GitHub. All dates were checked on 15 November 2026 and are in UTC.
| Tool | From source or export required | Interactive or static | Large-graph handling | Environment | Licence | Maintenance |
|---|---|---|---|---|---|---|
| tensorViz | From source. Runs one forward call of your nn.Module with real tensors, so it records the branches that call took. A source-only preview needs no run. No export step. |
Interactive canvas: pan, zoom, expand modules, search, code focus. SVG/PNG export. | Collapsed modules you expand or enter, layer search, and Layers and All operations views. An experimental fake-tensor tier records shapes without allocating tensor data. | Editor: VS Code 1.106+, Cursor, VSCodium. Coding-agent plugin for Claude Code, Codex and Cursor. Saved graphs open in a browser. No notebook integration is documented. | MIT for tensorViz code. The canvas is rendered with tldraw, which has its own licence. | Extension 0.1.47, 15 Nov 2026 (Marketplace and Open VSX) |
| Netron | A saved file is required: ONNX, TFLite, TorchScript, torch.export, Core ML, Keras and others. It does not run Python. |
Interactive viewer | Not specifically documented. | Browser (netron.app), desktop apps for macOS, Windows and Linux, and a netron Python package |
MIT | v9.3.6, 14 Nov 2026. Last commit 14 Nov 2026 |
| torchview | From a live model. Runs a forward pass with input_size or input_data. No export step. |
Static Graphviz diagram | The depth limit, rolling of recursive modules, and device='meta' to avoid allocating memory |
Notebooks (Jupyter, Colab) or a script. Needs the Graphviz dot binary. |
MIT | 0.2.7 on PyPI, 22 Apr 2025. Last commit 26 Feb 2026 |
| Model Explorer (Google AI Edge) | Export required. Its PyTorch support takes an ExportedProgram from torch.export.export. |
Interactive | Built for it: nested layers that expand or collapse, search, “show identical layers” and GPU-accelerated rendering | Browser UI from a local server, Colab, and a Hugging Face Space for uploaded models. On Windows, only through WSL. | Apache-2.0 | 0.1.34, 20 Oct 2026. Last commit 12 Nov 2026 |
| TensorBoard | From a live model through SummaryWriter.add_graph, which uses torch.jit.trace. You view a log directory. |
Interactive dashboard | Not specifically documented for PyTorch graphs. | Browser (tensorboard --logdir). In notebooks with %load_ext tensorboard. |
Apache-2.0 | 2.21.0, 29 Jun 2026. Last commit 4 Nov 2026 |
| torchviz | From an output tensor. Draws the autograd graph that produced it. | Static Graphviz diagram | None documented. | Notebook or script. Needs Graphviz. | MIT in the repository’s LICENSE. PyPI metadata says BSD. | 0.0.3, 2 Dec 2024. Last commit 30 Dec 2024 |
| torchinfo | From a live model. Runs a forward pass to fill in shapes. | Text table, not a graph | A depth setting limits nesting. |
Notebook, script or terminal | MIT | 1.8.0 on PyPI, 14 May 2023. Last commit 1 Nov 2026, not yet released. |
Also suggested: torchvista draws an interactive forward-pass graph inside web-based notebooks, with collapsible modules. It can draw a partial graph when an error occurs. Its licence is GPL-3.0, and version 0.2.13 came out on 5 Sep 2026.
03 / NO EXPORT STEP
How do I visualize a PyTorch model without exporting to ONNX?
Use a tool that runs the model in Python: tensorViz, torchview, torchvista, torchinfo or TensorBoard’s add_graph. Each needs an example input, because a PyTorch model’s shapes depend on what you call it with.
In tensorViz, click Open as Graph above the model class in your editor. It asks for the Python environment and an example input. You can also declare the input in a comment such as # tensorviz: input=1,16. It runs one forward call and saves the setup in tensorviz.toml for the next run. The quickstart walks through a ten-line model.
A capture describes that one call. Other inputs, batch sizes or branches the call did not take are not shown. tensorViz labels shapes as measured only when a capture recorded them. See what a capture proves.
04 / A COMMON CHOICE
Netron vs torchview: which should I use?
Use Netron when you have a file. It is the broadest viewer here. Its README lists ONNX, TensorFlow Lite, PyTorch, torch.export, ExecuTorch, TorchScript, TensorFlow, Core ML, OpenVINO, Keras, Caffe, Darknet, Safetensors and NumPy, plus experimental formats. It opens in a browser without installing anything. For checking what a converter produced, such as an ONNX or TFLite file before deployment, it is the right tool.
Use torchview when you have the Python model. Netron does not run Python, so it cannot open an nn.Module class from your source. A .pth state dict is “a Python dictionary object that maps each layer to its parameter tensor” (PyTorch). It holds weights, not the forward computation. torchview runs forward and draws modules, tensor operations and shapes as a Graphviz image in a notebook or file.
If you want the torchview approach but interactive, and beside the source in your editor, that is the case tensorViz is built for.
For a focused comparison that also includes TorchVista, see Netron alternative for PyTorch.
05 / EXPORT-BASED VIEWERS
Does Google Model Explorer work with any PyTorch model?
Model Explorer supports PyTorch models only in ExportedProgram form. You call torch.export.export(model, inputs) and pass the result to model_explorer.visualize_pytorch, or save a .pt2 file. Its documentation notes that the format has no API or schema stability. The exporting PyTorch version must also match the installed one.
The model therefore has to pass torch.export. PyTorch’s documentation says torch.export “does not capture Python control flow or data structures, unless using explicit control flow operators”. It errors out when it reaches untraceable code, and data-dependent control flow can need a rewrite, for example to torch.cond. Many models export cleanly. When one doesn’t, a forward-pass tool such as tensorViz or torchview can still draw the path one call took.
Model Explorer has the strongest documented large-graph features of these tools. For an exported model with thousands of operations, it is a good choice.
06 / SCALE
How do I visualize a large PyTorch model, like a transformer?
- Collapse by default. tensorViz shows modules as cards you expand or enter, with a breadcrumb back. Search accepts names (
conv1), types (type=Conv2d) or shapes (shape=256). Hits inside a collapsed module stay grouped until you open it. Model Explorer and torchvista also collapse nested layers. torchview limitsdepth. - Avoid allocating real tensors. torchview accepts
device='meta'. tensorViz has an experimentalfakeorautotrace tier that records shapes without tensor data. It retries once with real tensors if the model needs values. The default is real tensors. - Inspect weights before running. tensorViz can read a Hugging Face
.safetensorsheader with range requests. It shows tensor names, shapes and dtypes without downloading the weights or running Python. See Hugging Face models. This is a weight hierarchy, not an execution graph.
tensorViz does not publish a parameter-count limit; one has not been established. Memory, model construction and the forward call still matter.
07 / PICK BY TASK
When should I use each tool?
| If you want to… | Use | Why |
|---|---|---|
| Open an ONNX, TFLite, Core ML or Keras file | Netron | The widest format support, and it runs in a browser with nothing installed |
| Get parameter counts and per-layer shapes quickly | torchinfo | One call prints a table with parameters and mult-adds. No graph is needed. |
| Track loss, accuracy or other training metrics | TensorBoard | It is built for experiment logging. The graph view is one dashboard among many. |
| Browse a large exported or TFLite graph | Model Explorer | Hierarchical layers and GPU-accelerated rendering |
| Put a static architecture diagram in a notebook or paper | torchview | Graphviz output from a live model, no export |
| See an interactive graph inside a Jupyter or Colab cell | torchvista | Built for web-based notebooks. tensorViz has no documented notebook integration. |
| Debug gradients or see what autograd saves | torchviz | make_dot draws the backward graph, with show_saved=True |
Explore your own nn.Module beside its Python, with shapes, and go from a layer to its source | tensorViz | An editor extension with code focus. No export step. |
| Let a coding agent open and discuss the model graph | tensorViz | A plugin for Claude Code, Codex and Cursor, and MCP from the extension |
| Review how an architecture changed in a diff or pull request | tensorViz | Review model changes; diff a PyTorch model between git commits compares source review with rendering each revision separately. |
| Visualize JAX/Flax as well as PyTorch | tensorViz or Netron | tensorViz traces JAX and Flax programs in the editor. Netron lists JAX as experimental. Model Explorer needs a JAX model exported to TF SavedModel or StableHLO first. |
08 / A WORKED EXAMPLE
How do I visualize torchvision ResNet-18?
The same model is shown in each tool below. These snippets use each project’s documented API. They were not run for this page, so check the linked docs for your versions. ResNet-18 with weights=None needs no download.
tensorViz
Save this as resnet_view.py in a folder open in VS Code. The comment declares the example input, as in the input setup guide.
import torch
from torch import nn
from torchvision.models import resnet18
# tensorviz: input=1,3,224,224
class ResNet18View(nn.Module):
def __init__(self):
super().__init__()
self.net = resnet18(weights=None)
def forward(self, x):
return self.net(x)
- Install tensorViz, or run
code --install-extension tensorviz.tensorviz-vscode. - Click Open as Graph above
ResNet18View. Choose a Python environment withtorchandtorchvision. - Review the
[1, 3, 224, 224]input and run the capture. Expandnetto seeconv1,layer1–layer4andfc. Searchtype=Conv2d, or select a layer and turn on Code focus.
The graph shows the shapes from this one call. To browse without running, choose Inspect source only, but it records no shapes.
The same model in the other tools
import torch
from torchvision.models import resnet18
model = resnet18(weights=None).eval()
x = torch.randn(1, 3, 224, 224)
# torchinfo: a table of layers, shapes and parameters
from torchinfo import summary
summary(model, input_size=(1, 3, 224, 224))
# torchview: a static Graphviz diagram (needs the dot binary)
from torchview import draw_graph
draw_graph(model, input_size=(1, 3, 224, 224), expand_nested=True).visual_graph
# Model Explorer: export first, then open the local UI
import model_explorer
ep = torch.export.export(model, (x,))
model_explorer.visualize_pytorch("resnet18", exported_program=ep)
# Netron: save a file, then run `netron resnet18.onnx` or open it at netron.app
torch.onnx.export(model, (x,), "resnet18.onnx")
# TensorBoard: log the traced graph, then run `tensorboard --logdir runs`
from torch.utils.tensorboard import SummaryWriter
with SummaryWriter("runs/resnet18") as writer:
writer.add_graph(model, x)
# torchviz: the autograd graph behind one output
from torchviz import make_dot
make_dot(model(x).mean(), params=dict(model.named_parameters()))
For ONNX exporter options and requirements in your PyTorch version, see the PyTorch ONNX docs.
Sources and what we did not verify
tensorViz: docs.tensorviz.dev, specifically the quickstart, concepts, canvas, trace tiers and licensing pages. Also the VS Code Marketplace and Open VSX listings. The PyPI package named tensorviz is not this project.
Netron: README, releases and PyPI. torchview: README and PyPI. Model Explorer: README, API guide, limitations and PyPI. TensorBoard: torch.utils.tensorboard, TensorBoard in notebooks, GitHub and PyPI. torchviz: GitHub and PyPI. torchinfo: GitHub and PyPI. torchvista: GitHub and PyPI. PyTorch: torch.export and saving and loading models.
Not verified here: we did not benchmark any tool or measure maximum graph sizes. Cells that say “not specifically documented” mean we found no statement in that project’s docs, not that the feature is missing. The ResNet-18 snippets were not run for this page. Netron’s and TensorBoard’s handling of very large graphs is not covered here.
For a step-by-step starting point, see how to visualize a PyTorch model architecture.