Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about **How do I visualize a net in Pytorch** **in Python**. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

## How do I visualize a net in Pytorch?

**How do I visualize a net in Pytorch?**The

`make_dot`

expects a variable (i.e., tensor with`grad_fn`

), not the model itself.

**I visualize a net in Pytorch**The

`make_dot`

expects a variable (i.e., tensor with`grad_fn`

), not the model itself.

## Method 1

The `make_dot`

expects a variable (i.e., tensor with `grad_fn`

), not the model itself.

try:

x = torch.zeros(1, 3, 224, 224, dtype=torch.float, requires_grad=False) out = resnet(x) make_dot(out) # plot graph of variable, not of a nn.Module

## Method 2

Here is how you do it with `torchviz`

if you want to save the image:

# http://www.bnikolic.co.uk/blog/pytorch-detach.html import torch from torchviz import make_dot x=torch.ones(10, requires_grad=True) weights = {'x':x} y=x**2 z=x**3 r=(y+z).sum() make_dot(r).render("attached", format="png")

screenshot of image you get:

**Summery**

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

**Also, Read**