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. 在训练过程中可以正常显示,但是不训练就无法正常显示
相关推荐
IT_陈寒8 小时前
用了Proxy才发现以前的JavaScript白写了
前端·人工智能·后端
甲维斯9 小时前
Claude Opus5手搓“NewAPI Plus”首轮成果!
人工智能
程序猿DD9 小时前
分享两个我每天都在用的 Skill,拖进豆包就能跑,限时领 30 天会员
人工智能
阿里云大数据AI技术9 小时前
Agentic Search 2.0:从单轮对话迈向企业级 AI 搜索自动驾驶Agent
人工智能·elasticsearch·agent
东风破_9 小时前
从 messages 数组到 Memory:大模型到底是怎么“记住”上一轮对话的?
人工智能
AEI9 小时前
四年间大模型的演进历程
人工智能·面试·程序员
狂师10 小时前
阿里开源:skill-up,一款Agent Skill 评测工具!
人工智能·开源·agent
武子康10 小时前
同一套 Agent Runtime,为什么 Web、Headless 和 Python SDK 仍然不是同一个产品
人工智能·llm·agent
天天代码码天天10 小时前
一个纯 C 的 OCR Runtime,又向前走了一步:lw.PPOCR.C preview.5 发布
人工智能
程序员cxuan10 小时前
Claude 官方的学习教程,太强了。
人工智能·后端·程序员