当前位置: 首页 > news >正文

报名网站制作百度官网首页登陆

报名网站制作,百度官网首页登陆,龙岩互联网,网站建设主流技术tensorboard简介 TensorBoard 是一组用于数据可视化的工具。它包含在流行的开源机器学习库 Tensorflow 中.但是也可以独立安装&#xff0c;服务Pytorch等其他的框架 可以常常用来观察训练过程中每一阶段如何输出的 安装pip install tensorboard启动tensorboard --logdir<d…

tensorboard简介

TensorBoard 是一组用于数据可视化的工具。它包含在流行的开源机器学习库 Tensorflow 中.但是也可以独立安装,服务Pytorch等其他的框架
可以常常用来观察训练过程中每一阶段如何输出的

  • 安装
    pip install tensorboard
    
  • 启动
    tensorboard --logdir=<directory_name>
    
    会默认在6006端口打开,也可以自行制定窗口,如:
    tensorboard --logdir=logs --port=6007
    

用法

  1. 所在类:
    from torch.utils.tensorboard import SummaryWriter
    
    介绍:
    class SummaryWriter:"""Writes entries directly to event files in the log_dir to beconsumed by TensorBoard.The `SummaryWriter` class provides a high-level API to create an event filein a given directory and add summaries and events to it. The class updates thefile contents asynchronously. This allows a training program to call methodsto add data to the file directly from the training loop, without slowing downtraining."""
    
  2. 创建对象
    writer = SummaryWriter('logs') # 说明写入哪个文件夹
    
  3. 常用方法
    writer.add_image()   # 图像方式
    writer.add_scalar()  # 坐标方式writer.close()  # 使用完之后需要close
    

add_scalar()

    def add_scalar(self,tag,scalar_value,global_step=None,walltime=None,new_style=False,double_precision=False,):"""Add scalar data to summary.添加标量数据到summary中Args:tag (str): Data identifier 图表标题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 eventnew_style (boolean): Whether to use new style (tensor field) or oldstyle (simple_value field). New style could lead to faster data loading.Examples::from torch.utils.tensorboard import SummaryWriterwriter = SummaryWriter()x = range(100)for i in x:writer.add_scalar('y=2x', i * 2, i)writer.close()Expected result:.. image:: _static/img/tensorboard/add_scalar.png:scale: 50 %"""

注意:向writer中写入新事件的同时她也会保留上一个事件,这就会导致一些拟合出现问题
解决:删除之前的log文件,重新生成

add_image()

def add_image(self, tag, img_tensor, global_step=None, walltime=None, dataformats="CHW"):"""Add image data to summary.Note that this requires the ``pillow`` package.Args:tag (str): Data identifierimg_tensor (torch.Tensor, numpy.ndarray, 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 eventdataformats (str): Image data format specification of the formCHW, HWC, HW, WH, etc.Shape:img_tensor: Default is :math:`(3, H, W)`. You can use ``torchvision.utils.make_grid()`` toconvert 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 ascorresponding ``dataformats`` argument is passed, e.g. ``CHW``, ``HWC``, ``HW``."""

实践

如在tensorboard中展示图片:

from torch.utils.tensorboard import SummaryWriter
import numpy as np
from PIL import Imagewriter = SummaryWriter('logs')
image_path = './dataset2/train/ants_image/0013035.jpg'
img_PIL = Image.open(image_path)
img_array = np.array(img_PIL)
print(type(img_array))
print(img_array.shape)writer.add_image("test",img_array,1,dataformats='HWC') # 展示读取的图片for i in range(100):writer.add_scalar('y=2x', 3*i, i)     # 绘图writer.close()
  • writer.add_image中的参数

    def add_image(self, tag, img_tensor, global_step=None, walltime=None, dataformats="CHW"):
    

    名称、图形向量(ndarray类型),第几步(是滑动翻页那种的,这里相当于设定是第几页,每次向后设定时不会清除原来的数据)

当前代码效果如图:
在这里插入图片描述
修改图片后:

from torch.utils.tensorboard import SummaryWriter
import numpy as np
from PIL import Imagewriter = SummaryWriter('logs')
image_path = './dataset2/train/ants_image/5650366_e22b7e1065.jpg'
img_PIL = Image.open(image_path)
img_array = np.array(img_PIL)
print(type(img_array))
print(img_array.shape)# 这里更新,说明为第二步
writer.add_image("test",img_array,2,dataformats='HWC')for i in range(100):writer.add_scalar('y=2x', 3*i, i)writer.close()

拖拉就会发现有两张图
在这里插入图片描述

在这里插入图片描述

http://www.hkea.cn/news/10205/

相关文章:

  • 怀化三中网站优化关键词排名外包
  • 外国做愛视频网站公司软文怎么写
  • wordpress建站视频郑州粒米seo外包
  • 上海市建设委员会的网站查询系统一站式营销平台
  • 做网站应该注意什么google下载官方版
  • axure做网站原型教程免费二级域名分发网站源码
  • 商城网站建设论坛seo搜索引擎优化报价
  • 网站建设预算策划百度不让访问危险网站怎么办
  • 用discuz怎样做网站三明网站seo
  • .net开发微信网站杭州网站seo推广软件
  • 自动的网站制作最近的疫情情况最新消息
  • 网站的建立与运营站长域名查询工具
  • 公司独立网站平台建设宁波seo外包公司
  • 网站分页怎么做网站开发语言
  • 免费企业网站系统源码下载新闻投稿平台有哪些
  • 重庆专业网站开发服务营销推广渠道
  • 做gif的网站东莞seo报价
  • 网站菜单素材网站关键词优化排名技巧
  • 东莞微信网站建设更好公司网站建设公司好
  • 商城网站制作公司地址如何引流客源最快的方法
  • 网页美工设计的四大原则seo快速排名多少钱
  • 免费做外贸网站播放量自助下单平台
  • 哪里可以做网站手机如何制作网页链接
  • 怎么制作手机百度seo推广
  • 网站费有发票怎么做会计分录免费发布信息网网站
  • 大学生做社交网站有哪些名词解释seo
  • 石家庄哪里有做网站的北京seo服务
  • 无锡网站建设运营网络服务器
  • 1688首页跨境电商seo什么意思
  • 苏州高端网站建设企业最新网络营销方式