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 add pictures add_image and add_images in the form of torch.Tensor in tensorboard in Pytorch

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Pytorch in the use of tensorboard in the form of how to add torch.Tensor pictures add_image and add_images, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.

Add_image and add_images

Code:

From torch.utils.tensorboard import SummaryWriterimport numpy as npimg = np.zeros ((3,100,100)) img [0] = np.arange (0,100,100) .reshape (100,100) / 10000img [1] = 1-np.arange (0,100,100) .reshape (100,100) / 10000img_HWC = np.zeros ((100,100,3)) img_HWC [:,: 0] = np.arange (0,100,100) .reshape (10000) / 10000img_HWC [:,: 1] = 1-np.arange (0, 10000). Reshape (100,100) / 10000writer = SummaryWriter () writer.add_image ('my_image', img, 0) # If you have non-default dimension setting, set the dataformats argument.writer.add_image (' my_image_HWC', img_HWC, 0, dataformats='HWC') writer.close () # tensorboard-- logdir=runs

Show the running results:

Code:

From torch.utils.tensorboard import SummaryWriterimport numpy as npimg_batch = np.zeros ((16,3,100,100) for i in range (16): img_batch [I, 0] = np.arange (0,100) .reshape (100,100) / 10000 / 16 * I img_batch [I, 1] = (1-np.arange (0,10000) .reshape (100,100) / 10000) / 16 * iwriter = SummaryWriter () writer.add_images ('my_image_batch', img_batch) 0) writer.close () # tensorboard-- logdir=runs

Show the running results:

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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