# Graph Visualization

**URL:** <https://discuss.pytorch.org/t/graph-visualization/1558>\
**Category:** Uncategorized\
**Created:** [April 1, 2017, 2:52am UTC](https://discuss.pytorch.org/t/graph-visualization/1558 "2017-04-01T02:52:47Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![alan\_ayu](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alan_ayu/32/374_2.png) [@alan\_ayu](https://discuss.pytorch.org/u/alan_ayu)\
**Post date:** [April 1, 2017, 2:52am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/1 "2017-04-01T02:52:48Z")

</div>

Does PyTorch have any tool,something like TensorBoard in TensorFlow,to do graph visualization to help users understand and debug network?

---

<div class="post-metadata">

**Author:** ![mattmacy](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mattmacy/32/2260_2.png) [@mattmacy](https://discuss.pytorch.org/u/mattmacy)\
**Post date:** [April 1, 2017, 3:26am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/2 "2017-04-01T03:26:24Z")

</div>

Not that I am aware of. However, due to its dynamic nature, it is much easier to debug a network in pytorch than tensorflow.  
As one commenter on [Reddit](https://www.reddit.com/r/MachineLearning/comments/5w3q74/d_so_pytorch_vs_tensorflow_whats_the_verdict_on/?st=j0yoypcr&sh=a5a4df61) opines:  
“Debugging is easier because a specific line in your specific code (not something deep under your sess.run() that worked with a large/generated Graph object) fails. Your stack traces don’t fill up three screens and make you play the “spot the actual error!” scrolling game.”

I’ve found it fairly simple to just instrument the code as needed when things don’t go as planned.

---

<div class="post-metadata">

**Author:** ![xwgeng](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/xwgeng/32/6030_2.png) [@xwgeng](https://discuss.pytorch.org/u/xwgeng)\
**Post date:** [April 1, 2017, 3:34am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/3 "2017-04-01T03:34:50Z")

</div>

look at this post [Graph visualization](https://discuss.pytorch.org/t/print-autograd-graph/692/2?u=xwgeng)

---

<div class="post-metadata">

**Author:** ![alan\_ayu](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alan_ayu/32/374_2.png) [@alan\_ayu](https://discuss.pytorch.org/u/alan_ayu)\
**Post date:** [April 1, 2017, 3:52am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/4 "2017-04-01T03:52:06Z")

</div>

got it.thank you:+1:

---

<div class="post-metadata">

**Author:** ![zsp1197](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/z/90ced4/32.png) [@zsp1197](https://discuss.pytorch.org/u/zsp1197)\
**Post date:** [April 10, 2018, 10:52am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/5 "2018-04-10T10:52:15Z")

</div>

Try VisualDL: [https://github.com/PaddlePaddle/VisualDL](https://github.com/PaddlePaddle/VisualDL)

VisualDL could produce graph with the ONNX file.

---

<div class="post-metadata">

**Author:** ![nullgeppetto](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/nullgeppetto/32/40331_2.png) [@nullgeppetto](https://discuss.pytorch.org/u/nullgeppetto)\
**Post date:** [September 18, 2018, 5:32pm UTC](https://discuss.pytorch.org/t/graph-visualization/1558/6 "2018-09-18T17:32:41Z")

</div>

Hi @zsp1197, have you managed to plot the graph in VidualDL? I’m trying to do that for a very simple network, following [this](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/pytorch/TUTORIAL_EN.md) example.

What I understand is that I need to export my model in a onnx file, as follows:

```auto
import torch.onnx
dummy_input = Variable(torch.randn(4, 3, 32, 32))
torch.onnx.export(net, dummy_input, "model.onnx")

```

Then, VisualDL’s documentation suggests [this](https://github.com/PaddlePaddle/VisualDL#launch-visual-dl). However, in such a case I don’t what logdir to use.

---

<div class="post-metadata">

**Author:** ![lutzroeder](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/lutzroeder/32/6743_2.png) [@lutzroeder](https://discuss.pytorch.org/u/lutzroeder)\
**Post date:** [September 23, 2018, 1:18am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/7 "2018-09-23T01:18:18Z")

</div>

[Netron](https://github.com/lutzroeder/netron) can open ONNX files and supports reading basic sequential `pth` files.

Also check out this thread: [Print Autograd Graph](https://discuss.pytorch.org/t/print-autograd-graph).

---

<div class="post-metadata">

**Author:** ![spt](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@spt](https://discuss.pytorch.org/u/spt)\
**Post date:** [September 23, 2018, 6:50am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/8 "2018-09-23T06:50:48Z")

</div>

I have used Netron to visualize ONNX graphs. If you can export your model to ONNX successfully I would recommend giving it a try.

---

<div class="post-metadata">

**Author:** ![waleeka](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/waleeka/32/6345_2.png) [@waleeka](https://discuss.pytorch.org/u/waleeka)\
**Post date:** [December 9, 2018, 11:59pm UTC](https://discuss.pytorch.org/t/graph-visualization/1558/9 "2018-12-09T23:59:35Z")

</div>

Check out [HiddenLayer](https://github.com/waleedka/hiddenlayer). I wrote this tool to visualize network graphs, and more specifically to visualize them in a way that is easier to understand. It merges related nodes together (e.g. Conv/Relu/MaxPool) and folds repeating blocks into one box and adds a x3 to imply that the block repeats 3 times rather than drawing it three times. This helps when you try to draw big networks, such as ResNet and Inception.

 ![https://github.com/waleedka/hiddenlayer](https://raw.githubusercontent.com/waleedka/hiddenlayer/master/assets/readme_graph.png)

---

<div class="post-metadata">

**Author:** ![lorinczszabolcs](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/lorinczszabolcs/32/8095_2.png) [@lorinczszabolcs](https://discuss.pytorch.org/u/lorinczszabolcs)\
**Post date:** [December 11, 2018, 4:31pm UTC](https://discuss.pytorch.org/t/graph-visualization/1558/10 "2018-12-11T16:31:23Z")

</div>

Great visualization tool! I just tried to visualize my slightly more complex models, and it works seamlessly.

---

<div class="post-metadata">

**Author:** ![tariqdaouda](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tariqdaouda/32/13347_2.png) [@tariqdaouda](https://discuss.pytorch.org/u/tariqdaouda)\
**Post date:** [June 22, 2019, 1:38am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/11 "2019-06-22T01:38:44Z")

</div>

I’ve started a new project for experiment documentation ([Spyrkle](https://github.com/tariqdaouda/Spyrkle)).

It should be able to generate an interactive graph in an HTML page that you can style using CSS.

> <https://github.com/tariqdaouda/Spyrkle/blob/master/demos/demo_pyTorch_graph_only.py>

---

<div class="post-metadata">

**Author:** ![abhilash\_pinky](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/abhilash_pinky/32/13676_2.png) [@abhilash\_pinky](https://discuss.pytorch.org/u/abhilash_pinky)\
**Post date:** [January 6, 2020, 7:13am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/12 "2020-01-06T07:13:05Z")

</div>

@tariqdaouda great work i have few queries like can we use this for custom pytorch object detection architecture ??

---

<div class="post-metadata">

**Author:** ![Lindosun](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/l/838e76/32.png) [@Lindosun](https://discuss.pytorch.org/u/Lindosun)\
**Post date:** [January 6, 2020, 7:29am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/13 "2020-01-06T07:29:13Z")

</div>

Maybe you can try TensorBoardX.  
It is TensorBoard for PyTorch.

```auto
from tensorboardX import SummaryWriter
writer = SummaryWriter(path)
writer.add_scalars(path, {'Data1' :value1, 'Data2' :value2}, index)
writer.close()

```

---

<div class="post-metadata">

**Author:** ![tariqdaouda](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tariqdaouda/32/13347_2.png) [@tariqdaouda](https://discuss.pytorch.org/u/tariqdaouda)\
**Post date:** [January 6, 2020, 4:44pm UTC](https://discuss.pytorch.org/t/graph-visualization/1558/14 "2020-01-06T16:44:21Z")

</div>

@abhilash_pinky Should be possible, writing custom crawlers inheriting from pyTorchCrawlergives you a lot a possibilities.

---

<div class="post-metadata">

**Author:** ![mathematics](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mathematics/32/40082_2.png) [@mathematics](https://discuss.pytorch.org/u/mathematics)\
**Post date:** [April 19, 2020, 5:57am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/15 "2020-04-19T05:57:40Z")

</div>

It would be great if PyTorch have built in function for graph visualization.

---

<div class="post-metadata">

**Author:** ![nagapavan525](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/nagapavan525/32/27040_2.png) [@nagapavan525](https://discuss.pytorch.org/u/nagapavan525)\
**Post date:** [September 15, 2020, 9:30pm UTC](https://discuss.pytorch.org/t/graph-visualization/1558/16 "2020-09-15T21:30:50Z")

</div>

> [@nullgeppetto](#):
>
> ```auto
> import torch.onnx
> dummy_input = Variable(torch.randn(4, 3, 32, 32))
> torch.onnx.export(net, dummy_input, "model.onnx")
> 
> ```

Thank u so much…it helped me to visualize my ABCDs of resnet to understand it better.

---

<div class="post-metadata">

**Author:** ![Purushothaman\_Srikan](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/purushothaman_srikan/32/34348_2.png) [@Purushothaman\_Srikan](https://discuss.pytorch.org/u/Purushothaman_Srikan)\
**Post date:** [April 23, 2021, 11:16am UTC](https://discuss.pytorch.org/t/graph-visualization/1558/17 "2021-04-23T11:16:42Z")

</div>

@waleeka Will this tool support Autoencoders and Deep AutoEncoders?
