python - 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))
我的环境是:
- PyTorch:'1.7.1'
- 张量流:'2.4.1'
- 蟒蛇:3.8.8
LZ,帮帮我!
解决方案
这是一个令人讨厌的小错误,需要有人修补。这里有一个关于它的对话
我能够通过添加来修复它:
import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
到第 798 行上方的 torch/utils/tensorboard/writer.py
高能
推荐阅读
- python - python:如何在这段代码中删除 lambda?
- spring-boot - Websocket from UI connecting to one of the instances for Spring boot application for streaming the data coming on a queue
- linux - How can one greate grid/tile view of selected parts of windows on xfce/linux
- python - async-await SyntaxError in decorator aiogram
- reactjs - typescript err: must have a '[Symbol.iterator]()' method that returns an iterator when using react usereducer hook in context-why?
- python - KeyError:将数据上传到df之前的代码错误
- google-apps-script - 编写 googlefinance 包装器
- python - 如何检查用户 ID 是否已注册到机器人?[不和谐.py]
- nginx - nginx 中的多个位置不起作用 - 错误 404
- json - 将 JSON 解码并解析为 Lua