当前位置:网站首页>The network model established by torch is displayed by torch viz

The network model established by torch is displayed by torch viz

2022-07-06 08:33:00 MAR-Sky

torchviz.make_dot

MyConvNet = VGG() #  It can be a network 
x = torch.randn(4, 3, 256, 256).requires_grad_(True)  #  Define the input value of a network 
y = MyConvNet(x)    #  Get the predicted value of the network 

MyConvNetVis = make_dot(y, params=dict(list(MyConvNet.named_parameters()) + [('x', x)]))
MyConvNetVis.format = "png"
#  Specify the folder where the file is generated 
MyConvNetVis.directory = "data"
#  Generate the file 
MyConvNetVis.view()

We need to pay attention to , Input format It is the same as the input channel format defined by the network ;

rely on graphviz library

I see many things on the Internet that need to be downloaded graphviz Of zip or mis file , Also configure path; And then use python Proceed again pip After installation and restart, I don't know what the principle is . Personal attempts only require Install in the environment in use graphviz library You can use .

原网站

版权声明
本文为[MAR-Sky]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060827241528.html