Plot a graph in pytorch using tensorboard

I am trying to plot a graph using tensorboard in pytorch and I use this after I create a model:

input_tensor = torch.Tensor(1,1,28,28)
if args.cuda:
input_tensor = input_tensor.cuda()
res = model(Variable(input_tensor), requires_grad=True))
tb.add_graph(model, lastVar=res)

but I get this error :

File “/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py”, line 85, in forward
raise NotImplementedError

NotImplementedError

Thank you

Did you implement the forward method in your model class as:

def forward(self, x):
    # method body

?
The error means that model does not have a member function (method) overriding the nn.Module one.

1 Like