怎么安装查百度。

可视化神经网络图

第一步

代码部分:

  1. import torch
  2. import torch.nn as nn
  3. import torch.nn.functional as F
  4. import torchvision
  5. from tensorboardX import SummaryWriter
  6. class Net(nn.Module):
  7. def __init__(self):
  8. super(Net, self).__init__()
  9. self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
  10. self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
  11. self.conv2_drop = nn.Dropout2d()
  12. self.fc1 = nn.Linear(320, 50)
  13. self.fc2 = nn.Linear(50, 10)
  14. self.bn = nn.BatchNorm2d(20)
  15. def forward(self, x):
  16. x = F.max_pool2d(self.conv1(x), 2)
  17. x = F.relu(x) + F.relu(-x)
  18. x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
  19. x = self.bn(x)
  20. x = x.view(-1, 320)
  21. x = F.relu(self.fc1(x))
  22. x = F.dropout(x, training=self.training)
  23. x = self.fc2(x)
  24. x = F.softmax(x, dim=1)
  25. return x
  26. #定义输入
  27. input = torch.rand(32, 1, 28, 28)
  28. #实例化神经网络
  29. model = Net()
  30. #将model保存为graph
  31. with SummaryWriter(log_dir='logs',comment='Net') as w:
  32. w.add_graph(model, (input, ))

第二步

终端cd到该目录下(pycharm直接Terminal即可),输入下图中命令
image.png

第三步

在Edge浏览器输入http://localhost:6006即可

若出现”TensorFlow installation not found - running with reduced feature set“的报错,查看下面博客
image.png

详细参考文章

image.png

如何抹除旧的calar

到日志文件夹里面删除对应的日志文件即可。