Skip to main content
VisualTorch

python pytorch Downloads Run Tests Documentation Status

VisualTorch aims to help visualize Torch-based neural network architectures. It currently supports generating flow-style, graph-style, and LeNet-style architectures for PyTorch Sequential and Custom models. Its original visual styles were inspired by visualkeras, pytorchviz, pytorch-summary, and torchview; since then, it has grown its own unified tracing backend and architecture-handling logic well beyond its origins.

Note: 1.0+ is a major release with breaking API changes, but with significantly better features and algorithms - upgrading is recommended. For the old API, use 0.2.5 or older.

Limitation: VisualTorch traces a real forward pass to build the diagram, which has an inherent limitation shared by any tracing-based approach (not a bug, and not fixable without full symbolic execution): models with data-dependent control flow (e.g. a branch only taken if a tensor value crosses some threshold) only show whichever branch the traced dummy input happened to take. Separately, a layer that returns multiple meaningful output tensors (e.g. a custom multi-task head, or nn.LSTM's (output, (h_n, c_n))) still has its node's size based on only its first tensor; with show_dimension=True, every output tensor's shape is shown in the label, not just the first. Downstream connections are correct either way. Contributions are welcome!

VisualTorch Examples

Animated Reveal

Every style can also render as an animated GIF, revealing the model one layer/column at a time, via visualtorch.animate(model, input_shape, style=...) - see it in action for flow, graph, and lenet styles.

Animated VisualTorch Example

Documentation

Online documentation is available at visualtorch.readthedocs.io.

The docs include usage examples, API references, and other useful information.

Installation

See the Installation page.

MCP integration

VisualTorch includes an optional, client-neutral stdio MCP server for generating static PNG diagrams and animated GIF reveals from PyTorch model source. It exposes capability discovery, structured output metadata, documentation resources, subprocess timeouts, and all three canonical styles (graph, flow, and lenet). Install it with pip install "visualtorch[mcp]" and see the MCP integration guide for the tool schemas, generic stdio configuration, examples, and trusted-code security boundary. No client-specific plugin or extension is required.

Used in Research

VisualTorch has been used in published research, including works published in Nature, IEEE, and MDPI.

See the Research Showcase page for the full list.

Used VisualTorch in your research, built something with it, or found a paper that cites it? Tell us about it or open a pull request to add it directly - we'd love to hear.

Examples

See the Usage Examples page.

Contributing

Please feel free to send a pull request to contribute to this project by following this guideline.

Releases

See GOVERNANCE.md for release methodology and cadence, and the PyPI release history for past releases.

License

This poject is available as open source under the terms of the MIT License.

Originally, this project was based on the visualkeras (under the MIT license), with additional modifications inspired by pytorchviz, pytorch-summary, and torchview, all of which are also licensed under the MIT license.

Citation

Please cite this project in your publications if it helps your research.

Note: the paper below describes VisualTorch as of its publication date (2024). The project has since been substantially refactored, including breaking API changes (see the documentation for the current API) - the DOI always resolves to what was actually reviewed and published.

@article{Hendria2024,
  doi = {10.21105/joss.06678},
  url = {https://doi.org/10.21105/joss.06678},
  year = {2024},
  publisher = {The Open Journal},
  volume = {9},
  number = {102},
  pages = {6678},
  author = {Willy Fitra Hendria and Paul Gavrikov},
  title = {VisualTorch: Streamlining Visualization for PyTorch Neural Network Architectures},
  journal = {Journal of Open Source Software}
}

Star History

Star History Chart

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visualtorch-1.4.1.tar.gz (105.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

visualtorch-1.4.1-py3-none-any.whl (83.3 kB view details)

Uploaded Python 3

File details

Details for the file visualtorch-1.4.1.tar.gz.

File metadata

  • Download URL: visualtorch-1.4.1.tar.gz
  • Upload date:
  • Size: 105.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for visualtorch-1.4.1.tar.gz
Algorithm Hash digest
SHA256 14ba3c7782a0e36e112ebe4ba5e92b1bd58c743d72af10ed8f032bd0bcf3154a
MD5 961003cb14b8812fdf7f4ff019ac6da9
BLAKE2b-256 77b630cfaaea0f50100edda8a8b664b490cc3257cc9be6a6a730dcef23608a48

See more details on using hashes here.

File details

Details for the file visualtorch-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: visualtorch-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 83.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for visualtorch-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b34ca21e4004ee75e7d0d2d28fef7e970dd93353bada9f2a1f152c078b932da
MD5 ec61536d24124d60a3720a7107e9f688
BLAKE2b-256 5daa6baa1cbbe34ef10b7e80c8b24756f9b73cbcf176f0a8637c9c38d9868f23

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.4.1 This release

2 files

1.4.0

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page