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. 在训练过程中可以正常显示,但是不训练就无法正常显示
相关推荐
阿里云大数据AI技术11 分钟前
SENSER识季 × 阿里云OpenSearch:从时尚灵感到自我表达
人工智能
the3clipse18 分钟前
Windows 11 26H2 AI 功能使用指南:回顾、单击以执行与实时字幕
人工智能·windows·copilot+ pc·recall 回顾·单击以执行·实时字幕翻译·windows studio
geovindu25 分钟前
python:Logistic Regression
开发语言·后端·python·算法
OpenPie丨拓数派1 小时前
拓数派以产品化FDE基座赋能某世界500强医疗科技企业,打造基于本体论的DRG检验医保合规AI原生服务
人工智能
阿里云大数据AI技术2 小时前
Hologres 数据沙箱:让 AI 在隔离环境中安全探索和验证
人工智能
geovindu2 小时前
python: Random Forest
开发语言·后端·python·算法·随机森林
真上帝的左手2 小时前
2. 编程语言-Python-Anaconda
开发语言·python
aifannihao2 小时前
断言从 == 改成 > 0:用 Python 审出 git diff 里的测试降级
git·python·测试·标准库·代码审查
程序员cxuan2 小时前
Running Hub 上线 Motion
人工智能·aigc
高洁012 小时前
具身智能的人机协作与物理空间安全
人工智能·python·深度学习·机器学习·django