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. 在训练过程中可以正常显示,但是不训练就无法正常显示
相关推荐
程序员cxuan12 小时前
讲真,智能路由这事儿,还得看基元律动
人工智能·后端·程序员
zixu_star12 小时前
定时任务是什么?从日常自动化到 AI 应用,软件如何自动执行任务?
运维·人工智能·自动化
Baihai_IDP13 小时前
别再争论 AI 该不该像人了,赋予 AI 人格是非常有效的后训练策略
人工智能·llm·aigc
框架那些事儿13 小时前
一篇文章,搞懂 Agent 的工具调用机制
人工智能·全栈
用户0190275816113 小时前
Dify / Coze 低代码 Agent 怎么接 A 股行情?
python
武子康13 小时前
H3-World 写了 CPU offload,为什么还不能保证塞进 48GB?
大数据·人工智能·深度学习
Linye13 小时前
配了 3 套 AI 规则还打架?聊聊 Agent 信源仲裁与三层验真
人工智能·架构
雪庭13 小时前
WorkBuddy 专家包:AI 错题本管家开发全程复盘
人工智能
枕月而栖13 小时前
消息积压清不掉,ZEEKEAI 上用 Claude Fable 5.1 从消费指标里找到瓶颈
人工智能
nice_lcj52013 小时前
【从零理解 Spring AI · 16】Agent 与工作流:什么该写死,什么该让模型决定
java·人工智能·后端·spring ai·ai应用开发