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!
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 MCP server for generating architecture diagrams from model source
provided by an MCP client. Install it with pip install "visualtorch[mcp]" and see the
MCP integration guide
for configuration and usage details.
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file visualtorch-1.3.0.tar.gz.
File metadata
- Download URL: visualtorch-1.3.0.tar.gz
- Upload date:
- Size: 72.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c0d206adf7f0dbca6c3b2ee2cb3737e03e2aff20bfef02cc567a8e5212338d1
|
|
| MD5 |
141c45d6fbcbe92297eff5c5f06fdf68
|
|
| BLAKE2b-256 |
807dfe0856288e6f66fb45c8927e72092631af5c68ba80b50b10ade0006fffcf
|
File details
Details for the file visualtorch-1.3.0-py3-none-any.whl.
File metadata
- Download URL: visualtorch-1.3.0-py3-none-any.whl
- Upload date:
- Size: 59.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
022c56635d15b6a619d2441b2c36579b95df2f4d16540f2f92d0cd7dcbd3c5a3
|
|
| MD5 |
4c6d518ea658d8ea9504fb211a411378
|
|
| BLAKE2b-256 |
955bb534b016911f90430bd252665b059daa1286fee013f387363e1b8f68017b
|