首页 > 解决方案 > pytorch 张量板“add_embedding 错误”

问题描述

每个人。我被困在 pytorch 中使用 tensorboard。关键是 add_embedding 方法会产生如下错误:

Traceback (most recent call last):
  File "test2.py", line 126, in <module>
    writer.add_embedding(features, metadata=class_labels, label_img = images.unsqueeze(1))
  File "/home/dgjung/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/utils/tensorboard/writer.py", line 798, in add_embedding
    fs = tf.io.gfile.get_filesystem(save_path)
AttributeError: module 'tensorflow._api.v2.io.gfile' has no attribute 'get_filesystem'

我的代码是pytorch 教程

# log embeddings
features = images.view(-1, 28 * 28)
writer.add_embedding(features,
                    metadata=class_labels,
                    label_img=images.unsqueeze(1))

我的环境是:

LZ,帮帮我!

标签: pythonpytorch

解决方案


这是一个令人讨厌的小错误,需要有人修补。这里有一个关于它的对话

我能够通过添加来修复它:

import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile

到第 798 行上方的 torch/utils/tensorboard/writer.py

高能


推荐阅读