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}
}

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.0.tar.gz (56.0 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.0-py3-none-any.whl (46.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: visualtorch-1.2.0.tar.gz
  • Upload date:
  • Size: 56.0 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.0.tar.gz
Algorithm Hash digest
SHA256 9c54d788dcf59ec59d7c8c1f4e304eff446159c86acedd531496d2d1a245faa1
MD5 e5e1d2d0d8c37950c6206e2cdf4215a8
BLAKE2b-256 f3fd29b2540904bd7727b9dbfe507d724a65024ca7a9f10c6a0d46a1c28c1fa5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: visualtorch-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 46.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa04c698cf9129c49afe21f9e8319c0bd46351733206129e5f0b2b4b885ae587
MD5 7741bc928761d8d8089a5a434b657111
BLAKE2b-256 4c145ed3b0f03921584ecbb494b27001cbf75db13332b9a6a89f00a5aaef560c

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