Search code examples
pytorchtensorboard

Visualizing models, data, and training with tensorboard in pytorch


Following this Tutorial to visualize images in tensorboard using torch.utils.tensorboard got error

from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter('runs/fashion_mnist_experiment_1')
writer.add_embedding(features,
                metadata=class_labels,
                label_img=images.unsqueeze(1))
writer.close()

Error:

        AttributeError: module 'tensorflow_core._api.v2.io.gfile' has no attribute 'get_filesystem'

Solution

  • try adding

    writer = SummaryWriter(path)
    img_grid = torchvision.utils.make_grid(torch.FloatTensor(imgs)) #imgs represent a batch of images with shape BxCxHxW
    writer_add_image('images', img_grid)
    

    source : https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html#writing-to-tensorboard