Pytorch tensorboard colab tensorflow._api.v1.io.gfile';没有属性';获取文件系统
我想在colab上使用张力板。我设法使它工作,但不是所有的命令。add_graph和add_scalar有效,但当我尝试运行add_embedding时,出现以下错误:Pytorch tensorboard colab tensorflow._api.v1.io.gfile';没有属性';获取文件系统,pytorch,tensorboard,Pytorch,Tensorboard,我想在colab上使用张力板。我设法使它工作,但不是所有的命令。add_graph和add_scalar有效,但当我尝试运行add_embedding时,出现以下错误: AttributeError: module 'tensorflow._api.v1.io.gfile' has no attribute 'get_filesystem' 这是相关代码(我认为) 完全错误是: /tensorflow-1.15.0/python3.6/tensorflow_core/python/util/m
AttributeError: module 'tensorflow._api.v1.io.gfile' has no attribute 'get_filesystem'
这是相关代码(我认为)
完全错误是:
/tensorflow-1.15.0/python3.6/tensorflow_core/python/util/module_wrapper.py in __getattr__(self, name)
191 def __getattr__(self, name):
192 try:
--> 193 attr = getattr(self._tfmw_wrapped_module, name)
194 except AttributeError:
195 if not self._tfmw_public_apis:
AttributeError: module 'tensorflow._api.v1.io.gfile' has no attribute 'get_filesystem'
使用
- tensorflow-1.15.0(尝试安装2.0,但存在不同的问题)
- Python 3.6.9
- 火炬1.4.0
- 张力板2.1.1(也尝试使用1.15.0,但问题相同)
有什么建议可以让它工作吗?卸载tensorflow。不要将tensorflow与火炬安装在同一环境中。 如果您安装tensorflow,tensorboard可能会首先尝试使用tensorflow的api 然后您可能会遇到以下问题:“LocalFileSystem”对象没有属性“makedirs”
有一种解决办法——
- 卸载的tensorflow
- 重新安装的张力板
PS:重启内核和tensorboard
tensorboard 2.2.0和torch 1.14.0为我工作。我正在Colab中运行代码,它似乎与writer.py有问题
# helper function
def select_n_random(data, labels, n=100):
'''
Selects n random datapoints and their corresponding labels from a dataset
'''
assert len(data) == len(labels)
perm = torch.randperm(len(data))
return data[perm][:n], labels[perm][:n]
# select random images and their target indices
images, labels = select_n_random(trainset.data, trainset.targets)
# get the class labels for each image
class_labels = [classes[lab] for lab in labels]
# log embeddings
features = images.view(-1, 28 * 28)
writer.add_embedding(features,
metadata=class_labels,
label_img=images.unsqueeze(1))
writer.close()
在Colab中运行本教程时
对我来说,这解决了问题:
import tensorflow as tf
import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
这不是答案。如果可能,您可以在GitHub项目回购中报告错误。
# helper function
def select_n_random(data, labels, n=100):
'''
Selects n random datapoints and their corresponding labels from a dataset
'''
assert len(data) == len(labels)
perm = torch.randperm(len(data))
return data[perm][:n], labels[perm][:n]
# select random images and their target indices
images, labels = select_n_random(trainset.data, trainset.targets)
# get the class labels for each image
class_labels = [classes[lab] for lab in labels]
# log embeddings
features = images.view(-1, 28 * 28)
writer.add_embedding(features,
metadata=class_labels,
label_img=images.unsqueeze(1))
writer.close()
import tensorflow as tf
import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile