Pytorch 可視化筆記1:pytorchviz

(1)首先安裝graphviz

(2)命令行安裝pytorchviz

pip install git+https://github.com/szagoruyko/pytorchviz

(3)示例代碼

import torch
import torch.nn as nn
import torchviz
from torch.autograd import Variable

model = nn.Sequential()
model.add_module('W0',nn.Linear(8,16))
model.add_module('tanh', nn.Tanh())
model.add_module('W1',nn.Linear(16,1))

x = Variable(torch.randn(1,8))
y = model(x)

torchviz.make_dot(y.mean(), params=dict(model.named_parameters()))

 

參考文獻:

https://blog.csdn.net/nima1994/article/details/83008349

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章