如有报错
failed to execute ['dot', '-Tpdf', '-O', 'Digraph.gv'], make sure the Graphviz executables are on your systems' PATH
需要
sudo pip install graphviz
sudo pip install torchviz
(pip install git+https://github.com/szagoruyko/pytorchviz )
使用时:
import torch
from torchviz import make_dot
from deeplabv3plus import *
model = DeepLabv3_plus(nInputChannels=3,
nOutChannels=2, os=16, pretrained=False, _print=True)
x = torch.randn(4, 3, 320, 320)
y = model(x)
# 生成图
g = make_dot(y,params=dict(list(model.named_parameters())))
g.view()