gpt4 book ai didi

python - 无法使用 torch.utils.tensorboard.SummaryWriter.add_graph 方法加载保存的图形

转载 作者:太空宇宙 更新时间:2023-11-04 04:04:04 26 4
gpt4 key购买 nike

我使用 torch.utils.tensorboard.SummaryWriter 中的 add_scalaradd_graph 方法保存标量摘要和模型图。

在摘要文件上运行 tensorboard 时,它不显示模型图。右下角只有2个小矩形,但可以显示标量变量和图像。

随附的 pytorch 文档中的示例代码

import torch
import torchvision
from torch.utils.tensorboard import SummaryWriter
from torchvision import datasets, transforms

# Writer will output to ./runs/ directory by default
writer = SummaryWriter()

transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,))])
trainset = datasets.MNIST('mnist_train', train=True, download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)
model = torchvision.models.resnet50(False)

print(model)

# Have ResNet model take in grayscale rather than RGB
model.conv1 = torch.nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)
images, labels = next(iter(trainloader))

grid = torchvision.utils.make_grid(images)
writer.add_image('images', grid, 0)
writer.add_graph(model, images)
writer.close()

任何指向解决方案的指针将不胜感激

PyTorch version - 1.2.0 Tensorboard version - 1.15.0a20190828

Attaching the bottom right crop of the tensorboard

最佳答案

我遇到了同样的问题。看看这个线程: https://github.com/pytorch/pytorch/issues/24157

TLDR:将 PyTorch 更新为 PyTorch-nightly,问题应该可以解决。 https://pytorch.org/get-started/locally/

关于python - 无法使用 torch.utils.tensorboard.SummaryWriter.add_graph 方法加载保存的图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57706256/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com