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. 在训练过程中可以正常显示,但是不训练就无法正常显示
相关推荐
一点一木2 小时前
深度体验TRAE SOLO移动端7天:作为独立开发者,我把工作流揣进了兜里
前端·人工智能·trae
Lee川2 小时前
mini-cursor 揭秘:从 Tool 定义到 Agent 循环的完整实现
前端·人工智能·后端
weelinking3 小时前
【产品】00_产品经理用Claude实现产品系列介绍
数据库·人工智能·sql·数据挖掘·github·产品经理
Agent产品评测局3 小时前
制造业模具管理AI系统,主流产品能力对比详解:2026年智能制造选型深度洞察
人工智能·ai·chatgpt·制造
2301_803934613 小时前
Go语言如何做网络爬虫_Go语言爬虫开发教程【指南】
jvm·数据库·python
WL_Aurora3 小时前
Python爬虫实战(六):新发地蔬菜价格数据采集.
爬虫·python
盲敲代码的阿豪3 小时前
Python 入门基础教程(爬虫前置版)
开发语言·爬虫·python
研华科技Advantech4 小时前
如何用一套实训设备,打通工业AI预测性维护技术全流程?
人工智能
Lab_AI4 小时前
AI for Science: MaXFlow AI Agent+ 报告体验双升级,让AI智能体更高效易用!
人工智能·ai for science·ai agent·ai智能体
李坤4 小时前
让 Codex 和 Claude 互相 Review:告别手动复制
人工智能·openai·claude