Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/szagoruyko/pytorchviz
A small package to create visualizations of PyTorch execution graphs
https://github.com/szagoruyko/pytorchviz
Last synced: 7 days ago
JSON representation
A small package to create visualizations of PyTorch execution graphs
- Host: GitHub
- URL: https://github.com/szagoruyko/pytorchviz
- Owner: szagoruyko
- License: mit
- Created: 2018-01-30T15:37:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-30T21:14:55.000Z (about 2 months ago)
- Last Synced: 2025-02-07T14:00:35.586Z (14 days ago)
- Language: Jupyter Notebook
- Size: 144 KB
- Stars: 3,291
- Watchers: 31
- Forks: 280
- Open Issues: 34
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-pytorch-list-CNVersion - pytorchviz
- Awesome-pytorch-list - pytorchviz
README
PyTorchViz
=======A small package to create visualizations of PyTorch execution graphs and traces.
[](https://colab.research.google.com/github/szagoruyko/pytorchviz/blob/master/examples.ipynb)
## Installation
Install graphviz, e.g.:
```
brew install graphviz
```Install the package itself:
```
pip install torchviz
```## Usage
Example usage of `make_dot`:
```
model = nn.Sequential()
model.add_module('W0', nn.Linear(8, 16))
model.add_module('tanh', nn.Tanh())
model.add_module('W1', nn.Linear(16, 1))x = torch.randn(1, 8)
y = model(x)make_dot(y.mean(), params=dict(model.named_parameters()))
```
Set `show_attrs=True` and `show_saved=True` to see what autograd saves for the backward pass. (Note that this is only available for pytorch >= 1.9.)
```
model = nn.Sequential()
model.add_module('W0', nn.Linear(8, 16))
model.add_module('tanh', nn.Tanh())
model.add_module('W1', nn.Linear(16, 1))x = torch.randn(1, 8)
y = model(x)make_dot(y.mean(), params=dict(model.named_parameters()), show_attrs=True, show_saved=True)
```
## Acknowledgements
The script was moved from [functional-zoo](https://github.com/szagoruyko/functional-zoo) where it was created with the help of Adam Paszke, Soumith Chintala, Anton Osokin, and uses bits from [tensorboard-pytorch](https://github.com/lanpa/tensorboard-pytorch).
Other contributors are [@willprice](https://github.com/willprice), [@soulitzer](https://github.com/soulitzer), [@albanD](https://github.com/albanD).