Display pytorch or tensorflow graph with a value at each node

232 Views Asked by At

In tensorboard, it is possible to plot the computational graph of a deep learning model.

  • Is it possible to display a value for each node (for example, the norm of the output)?
  • Is it possible to do it in both pytorch and tensorflow?

Example (display computational graph with torch.norm of output of each computational graph's node in vgg11):

import torch
import torchvision

vgg11 = torchvision.models.vgg11(pretrained=True)
image = torch.randn(8, 3, 224, 224)
out = vgg11(image)

So in the output node, we want the value in the computational graph to be

torch.norm(out)

One issue in pytorch side is that, there is no explicit computational graph to visualize (e.g. in pydot).

1

There are 1 best solutions below

6
On

This is a poor question, but:

Yes is is possible.

Access the underlying internal members via the _ or __ prefix and calculate the norm...

So yes it is possible, but the same code will not work across frameworks.