Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use tensorboard in Pytorch

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to use tensorboard in Pytorch. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Installation: pip install tensorboard

Or install tensorflow. The default CPU version is pip install tensorflow.

Run: tensorboard-- logdir=runs

Lab code:

Import torchimport torchvisionfrom torch.utils.tensorboard import SummaryWriterfrom torchvision import datasets, transforms# Writer will output to. / runs/ directory by defaultwriter = SummaryWriter () transform= transforms.Compose ([transforms.ToTensor (), transforms.Normalize ((0.5,), (0.5,)]) trainset = datasets.MNIST ('mnist_train', train=True, download=True, transform=transform) trainloader = torch.utils.data.DataLoader (trainset, batch_size=64, shuffle=True) model = torchvision.models.resnet50 (False) # Have ResNet model take in grayscale rather than RGBmodel.conv1 = torch.nn.Conv2d (1 64, kernel_size=7, stride=2, padding=3, bias=False) images, labels = next (iter (trainloader)) grid = torchvision.utils.make_grid (images) writer.add_image ('images', grid, 0) writer.add_graph (model, images) writer.close ()' tensorboard-- logdir=runs'''

After running, type: tensorboard-- logdir=runs at the command line

When prompted, open the link: http://localhost:6006/

The output under the command line is:

(base) PS C:\ Users\ chenxuqi\ Desktop\ News4cxq\ tensorboard4cxq > conda activate pytorch_1.7.1_cu102 (pytorch_1.7.1_cu102) PS C:\ Users\ chenxuqi\ Desktop\ News4cxq\ tensorboard4cxq > tensorboard-logdir=runsTensorFlow installation not found-running with reduced feature set.Serving TensorBoard on localhost; to expose to the network, use a proxy or pass-bind_allTensorBoard 2.4.0 at http://localhost:6006/ (Press CTRL+C to quit)

Display effect under the browser:

This is how to use tensorboard in the Pytorch shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report