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. 在训练过程中可以正常显示,但是不训练就无法正常显示
相关推荐
W_326003 分钟前
Python 组合数据类型——序列(列表 & 元组)
开发语言·python
江畔柳前堤9 分钟前
YOLO 目标检测全流程深度剖析
人工智能·yolo·目标检测·计算机视觉·unity·面试·vllm
jikemaoshiyanshi9 分钟前
业务部门想了解开箱即用 AI Agent,AWS 中国峰会有哪些案例展示?
大数据·人工智能
2401_8322981013 分钟前
绿色AI发展新赛道:算力优化与低碳智能的双向赋能
人工智能
Z-D-K27 分钟前
一个AI的真实日记(3)
人工智能·ai·aigc·人机交互·agent·agi
二进制杯莫停30 分钟前
A和B环境的python版本相同,B环境无法安装pip依赖,离线安装
开发语言·python·pip
ivywriter32 分钟前
【数字孪生】到底能解决什么实际问题?
大数据·人工智能·机器人
(轻舟已过万重山)35 分钟前
第39章 评估迭代:上线只是开始,迭代才是关键
大数据·数据库·人工智能
听你说3235 分钟前
鹏辉LIC+EDLC高功率电容解决方案,为工业自动化、智能IoT、UPS备电等高负载设备而生
人工智能·物联网·自动化·创业创新
墨染天姬40 分钟前
【AI】从MOE混合专家到 MOA混合智能体
人工智能