当前位置:网站首页>使用PyTorch的TensorBoard-可视化深度学习指标 | PyTorch系列(二十五)
使用PyTorch的TensorBoard-可视化深度学习指标 | PyTorch系列(二十五)
2022-07-28 01:44:00 【51CTO】
文 |AI_study

原标题:TensorBoard With PyTorch - Visualize Deep Learning Metrics
在本系列的这一点上,我们刚刚完成了训练过程中的网络运行。现在,我们希望获得有关此过程的更多指标,以更好地了解幕后情况。
鸟瞰我们在训练过程中所处的位置。
- 准备数据
- 建立模型
- 训练模型
- 分析模型的结果
- 为此使用TensorBoard
TensorBoard:TensorFlow的可视化工具包
TensorBoard提供了机器学习实验所需的可视化和工具:
- 跟踪和可视化指标,例如损失和准确性
- 可视化模型图(操作和图层)
- 查看权重,偏差或其他张量随时间变化的直方图
- 将embedding 投影到较低维度的空间
- 显示图像,文本和音频数据
- 分析TensorFlow程序
- 以及更多
从PyTorch 1.1.0版开始,PyTorch添加了一个tensorboard实用程序包,使我们能够将TensorBoard与PyTorch一起使用。
为PyTorch安装TensorBoard
要为PyTorch安装TensorBoard,请执行以下步骤:
- 确认您正在运行PyTorch版本1.1.0或更高版本。
- 确认您正在运行TensorBoard 1.15或更高版本。
- 请注意,PyTorch使用的TensorBoard与为TensorFlow创建的TensorBoard相同。使用以下命令检查系统上安装的TensorBoard的版本:
4. 使用以下命令安装TensorBoard。
- 一旦安装了TensorBoard 1.15或更高版本,我们就可以开始了!
请注意,PyTorch文档说TensorBoard版本1.14是必需的。
PyTorch的TensorBoard入门
TensorBoard是一个字体结尾的Web界面,实际上从文件中读取数据并显示它。要使用TensorBoard,我们的任务是将我们要显示的数据保存到TensorBoard可以读取的文件中。
为了使我们更轻松,PyTorch创建了一个名为SummaryWriter的实用程序类。要访问此类,我们使用以下导入:
导入该类后,我们可以创建该类的实例,然后将其用于将数据从程序中获取到文件系统中,然后由TensorBoard进行使用。
网络图和训练集图像
SummaryWriter类带有许多方法,我们可以调用这些方法来有选择地选择和选择我们希望TensorBoard可以使用的数据。首先,我们将网络和一批图像传递给编写者。
该代码为TensorBoard创建一个名为tb的SummaryWriter实例。然后,创建我们的PyTorch网络的实例,并从我们的PyTorch数据加载器对象中解压缩一批图像和标签。
然后,将图像和网络添加到TensorBoard将使用的文件中。实际上,可以说网络图和图像的batch都已添加到TensorBoard中。
运行TensorBoard
要启动TensorBoard,我们需要在终端上运行tensorboard命令。这将启动一个本地服务器,该服务器将为TensorBoard UI和我们的SummaryWriter写入磁盘的数据提供服务。
默认情况下,PyTorch SummaryWriter对象将数据写入在当前工作目录中创建的名为./runs的目录中的磁盘。
当运行tensorboard命令时,我们传递一个参数来告诉tensorboard数据在哪里。就像这样:
TensorBoard服务器将启动并正在侦听端口6006上的http请求。这些详细信息将显示在控制台中。
通过浏览至以下位置访问TensorBoard UI:
在这里,我们将能够看到我们的网络图和图像数据。目前,这确实为我们提供了视觉效果,但没有接下来的有用。
TensorBoard直方图和标量
我们可以添加到TensorBoard的下一个数据导入类型是数字数据。我们可以添加将随时间或epoch 显示的标量值。我们还可以将值添加到直方图中以查看值的频率分布。
要添加标量和直方图,我们使用PyTorch SummaryWriter类提供的相应方法。
这是调用的示例:
这是一个示例,说明了如何将这些调用放在训练循环中:
这会将这些值添加到TensorBoard中。这些值甚至在网络训练时实时更新。
随时间推移查看损失和准确性值会很有帮助。但是,我们可能需要承认,实际上并不需要TensorBoard。
TensorBoard的真正功能是它具有开箱即用的比较多个运行的功能。这使我们能够通过更改超参数值并比较运行来快速进行实验,以查看哪些参数最有效。
文章中内容都是经过仔细研究的,本人水平有限,翻译无法做到完美,但是真的是费了很大功夫,希望小伙伴能动动你性感的小手,分享朋友圈,支持一下我 ^_^
英文原文链接是:
https://deeplizard.com/learn/video/pSexXMdruFM




边栏推荐
- [in depth study of 4g/5g/6g topic -42]: urllc-14 - in depth interpretation of 3GPP urllc related protocols, specifications and technical principles -8-low delay technology-2-slot based scheduling and
- Retainface use error: modulenotfounderror: no module named'rcnn.cyton.bbox'
- unordered_map的hash function及hash bucket存储方式探索
- Three core issues of concurrent programming (glory Collection Edition)
- Representation of children and brothers of trees
- [hcip] BGP Foundation
- 2022.7.8 eth price analysis
- How is insert locked in MySQL? (glory Collection Edition)
- 【图像隐藏】基于DCT、DWT、LHA、LSB的数字图像信息隐藏系统含各类攻击和性能参数附matlab代码
- [tutorial of using idea] shortcut key of idea
猜你喜欢

The virtual host website cannot access the self-test method

关于Sqli-labs单引号不报错的问题

【TA-霜狼_may-《百人计划》】图形3.7 移动端TP(D)R架构

"The faster the code is written, the slower the program runs"

Explore flex basis

Center-based 3D Object Detection and Tracking(基于中心的3D目标检测和跟踪 / CenterPoint)论文笔记

LETV responded that employees live an immortal life without internal problems and bosses; Apple refuses to store user icloud data in Russia; Dapr 1.8.0 release | geek headlines

Red hat official announced the new president and CEO! Paul Cormier, a key figure in transformation, is "retiring"

POC simulation attack weapon - Introduction to nucleus (I)

Notes for the fourth time of first knowing C language
随机推荐
D multi production single consumption
1313_pyserial的安装以及文档的生成
Leetcode judge whether palindrome number
第三章 队列
[signal denoising] signal denoising based on Kalman filter with matlab code
[elm classification] classification of UCI data sets based on nuclear limit learning machine and limit learning machine, with matlab code
QT implementation disable shortcut key
IO流:节点流和处理流详细归纳。
【OpenGL】GLES20.glClear
windbg
Manual installation of Dlib Library
特征值和特征向量
MySQL blocking monitoring script
[tutorial of using idea] shortcut key of idea
Cesium3Dtilesets 使用customShader的解读以及泛光效果示例
Wechat campus maintenance and repair applet graduation design finished product of applet completion work (4) opening report
windbg
初识C语言 -- 操作符和关键字,#define,指针
Sword finger offer special assault edition day 12
unordered_map的hash function及hash bucket存储方式探索