pytorch 训练可视化

pytorch 训练可视化

  • [1.from torch.utils.tensorboard](#1.from torch.utils.tensorboard)

1.from torch.utils.tensorboard

python 复制代码
from torch.utils.tensorboard import SummaryWriter

在最新版本的pytorch中官方提供了tensorboard的api。以下是官方教程的链接

text 复制代码
https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html?highlight=tensorboard

##1. TensorBoard setup

python 复制代码
from torch.utils.tensorboard import SummaryWriter
# default `log_dir` is "runs" - we'll be more specific here
writer = SummaryWriter('runs/fashion_mnist_experiment_1') # 创建一个保存日志的目录

##2. Writing to TensorBoard

在TensorBoard上显示图片,这里使用网格来显示。使用 make_grid 方法

python 复制代码
# 获取随机的训练图片
dataiter = iter(trainloader)
images, labels = dataiter.next()

# 构造网格布局的图片
img_grid = torchvision.utils.make_grid(images)

# 显示图片
matplotlib_imshow(img_grid, one_channel=True)

# 写入tensorboard
writer.add_image('four_fashion_mnist_images', img_grid)

在终端运行

shell 复制代码
tensorboard --logdir=runs

#已知问题及可能解决办法

##1.TensorFlow installation not found - running with reduced feature set.

打开网页后无反应。

解决办法:1.将tensorboard 回调到1.15版本。

  1. 在训练过程中可以正常显示,但是不训练就无法正常显示
相关推荐
ai产品老杨20 小时前
打通各大芯片厂商相互间的壁垒,省去繁琐重复的适配流程的智慧工业开源了
人工智能·开源·音视频·能源
小陈phd21 小时前
高级RAG策略学习(五)——llama_index实现上下文窗口增强检索RAG
人工智能
凯禾瑞华养老实训室1 天前
人才教育导向下:老年生活照护实训室助力提升学生老年照护服务能力
人工智能
luckys.one1 天前
第9篇:Freqtrade量化交易之config.json 基础入门与初始化
javascript·数据库·python·mysql·算法·json·区块链
湫兮之风1 天前
Opencv: cv::LUT()深入解析图像块快速查表变换
人工智能·opencv·计算机视觉
大翻哥哥1 天前
Python 2025:量化金融与智能交易的新纪元
开发语言·python·金融
Christo31 天前
TFS-2018《On the convergence of the sparse possibilistic c-means algorithm》
人工智能·算法·机器学习·数据挖掘
qq_508823401 天前
金融量化指标--2Alpha 阿尔法
大数据·人工智能
黑金IT1 天前
`.cursorrules` 与 `.cursorcontext`:Cursor AI 编程助手时代下的“双轨配置”指南
人工智能
zhousenshan1 天前
Python爬虫常用框架
开发语言·爬虫·python