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 分钟前
手机拍屏幕行为模型二次训练方案
人工智能
BD_Marathon7 分钟前
【Python】标准多态和鸭子多态
python
木头科技8 分钟前
【AI 工程化第十六篇】Spring AI 多模态 RAG 实战:图片、扫描件、表格与图文证据链
java·人工智能·spring
龙石数据9 分钟前
龙石 AI 智能体开发平台入选2026全球数据管理峰会数据治理创新实践案例
大数据·人工智能
ZDGJ609910 分钟前
个人参与国际期货交易有哪些优势
人工智能
用户83562907805111 分钟前
Python 操作 Excel:创建数组公式与 R1C1 公式
后端·python
阿尔法工场研究院13 分钟前
物理AI的GPT时刻快到了?
人工智能·机器人
wshzd14 分钟前
LLM之Agent(120)|DeepSeek-Harness(二十七)Workflow 引擎与 Ralph 循环
前端·数据库·人工智能
兰亭妙微UI设计公司18 分钟前
兰亭妙微ui设计公司分享:用AI原型提前发现复杂交互问题
人工智能
AAwangzong19 分钟前
企业级AI智能体厂商对比:模型服务、Agent平台与流程自动化如何选择?
人工智能·经验分享·rpa·智能体