tensorboard的使用

官方文档

# writer.add_scalar()  # 添加标量
"""
Args:
tag (string): Data identifier # 图表的Title
scalar_value (float or string/blobname): Value to save # 对应的y轴
global_step (int): Global step value to record # 对应的x轴
walltime (float): Optional override default walltime (time.time())
with seconds after epoch of event
""" # demo
from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter('runs') # 实例化一个对象
for i in range(100):
writer.add_scalar("y=x^2", i**2, i) # 分别对应title y轴 x轴
writer.close()
# writer.add_image()  # 添加图片
"""Add image data to summary. Note that this requires the ``pillow`` package. Args:
tag (string): Data identifier
img_tensor (torch.Tensor, numpy.array, or string/blobname): Image data
global_step (int): Global step value to record
walltime (float): Optional override default walltime (time.time())
seconds after epoch of event
Shape:
img_tensor: Default is :math:`(3, H, W)`. You can use ``torchvision.utils.make_grid()`` to
convert a batch of tensor into 3xHxW format or call ``add_images`` and let us do the job.
Tensor with :math:`(1, H, W)`, :math:`(H, W)`, :math:`(H, W, 3)` is also suitable as long as
corresponding ``dataformats`` argument is passed, e.g. ``CHW``, ``HWC``, ``HW``. Examples:: from torch.utils.tensorboard import SummaryWriter
import numpy as np
img = np.zeros((3, 100, 100))
img[0] = np.arange(0, 10000).reshape(100, 100) / 10000
img[1] = 1 - np.arange(0, 10000).reshape(100, 100) / 10000 img_HWC = np.zeros((100, 100, 3))
img_HWC[:, :, 0] = np.arange(0, 10000).reshape(100, 100) / 10000
img_HWC[:, :, 1] = 1 - np.arange(0, 10000).reshape(100, 100) / 10000 writer = 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() Expected result: .. image:: _static/img/tensorboard/add_image.png
:scale: 50 % """
# demo
from torch.utils.tensorboard import SummaryWriter
import cv2
write = SummaryWriter("logs")
img_array1 = cv2.imread('./dog.jpeg') # 读取图片,类型为ndarray
write.add_image("img", img_array1, 1, dataformats='HWC') # title, 数据: ndarray/tensor step 数据的类型: 默认:'CHW'
write.close()

开启面板

# 方法1: tensorboard --logdir=runs
# 方法2: tensorboard --logdir runs
# 方法3: tensorboard --logdir=runs --port=6007 如果端口冲突使用不冲突的端口

最新文章

  1. Oracle同义词
  2. Yii2 定时任务创建(Console 任务)
  3. sql执行
  4. ASP.NET AJAX Control Toolkit
  5. JNDI 是什么
  6. 解决Cisco VPN Client:Reason 442: Failed to Enable Virtual Adapter VPN连接问题
  7. [置顶] js对象
  8. 第06讲- DDMS中logcat的使用
  9. windows 7 旗舰版 切换 中英文 界面
  10. 超高性能的json序列化
  11. C++中的基本数据类型
  12. I/O模型
  13. React文档(二十二)context
  14. 应届生第一次Java面试问题分享
  15. govendor 无法添加.h文件
  16. (转载)中文Appium API 文档
  17. XQuery使用sum求和,提示char不能转换为money解决方法
  18. java web 读取文件,文件路劲不对的问题
  19. 如何从MTK机器的NVRAM中获取WIFI mac地址
  20. java 错误:无法找到或装入主类

热门文章

  1. 让弹幕给 PPD 生个孩子
  2. 10行 JavaScript 实现文本编辑器
  3. H5移动端开发
  4. Linux 0.11源码阅读笔记-高速缓冲
  5. Java/C++实现备忘录模式--撤销操作
  6. 关于recyclerview其item数据重复问题
  7. java中什么是Interface接口, 请给个实例!
  8. web.xml的作用及基本配置
  9. Restful API和传统的API的区别
  10. Odoo 服务器搭建备忘