Skip to main content

Architecture visualization of Torch models

Project description

🔥 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

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.

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.

Examples

See the Usage Examples page.

Contributing

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

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

Project details


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.2.1.tar.gz (57.9 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.2.1-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for visualtorch-1.2.1.tar.gz
Algorithm Hash digest
SHA256 1e320d39617ad3ac69ad9644f1592085d43ecef777baeaf0036d126423231750
MD5 74688a772918f8c7dda28764fb21919a
BLAKE2b-256 fc649a631a8ffe2e99f0a8258e8baaf7ca3e64a9567fee4dda8c1a1a6b6acb3f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for visualtorch-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3dae258285dc1301e2a9aa569a8d0d35f02e68b0098948ff3a5aa0429e4a2ed5
MD5 efca326ab705682a97a91906ccbb6c62
BLAKE2b-256 9f9d2692f1210e940399ab84a1364983dad4e5ecef8c578957a9cff34eea6400

See more details on using hashes here.

Supported by

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