[英]Still getting AttributeError: module 'tensorflow' has no attribute 'gfile' after trying every thing to solve that
I'm still getting this error after running this code with tf.gfile.GFile
and also tf.io.gfile.GFile
.Can you help me?使用tf.gfile.GFile
和tf.io.gfile.GFile
运行此代码后,我仍然收到此错误。你能帮我吗?
Windows 10视窗 10
tensorflow GPU version: 2.1.0张量流 GPU 版本:2.1.0
Code代码
`import tensorflow.compat.v1 as tf
detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
`
and also this code:还有这个代码:
` `
import tensorflow as tf
detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.io.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
` `
So I have solved this by uninstalling TensorFlow 2.xx, please install the last version of 1x TensorFlow which is 1.15所以我通过卸载 TensorFlow 2.xx 解决了这个问题,请安装 1x TensorFlow 的最新版本,即1.15
If you are using Google colab, use the command to install tensorflow 1.15: !pip3 install tensorflow==1.15
如果您使用的是 Google colab,请使用以下命令安装 tensorflow 1.15: !pip3 install tensorflow==1.15
Also, you can use %tensorflow_version 1.x
at the top to make sure only 1x is working for your notebook此外,您可以在顶部使用%tensorflow_version 1.x
以确保只有 1x 适用于您的笔记本
Copy both codes from here: !pip3 install tensorflow==1.15
%tensorflow_version 1.x
从这里复制两个代码: !pip3 install tensorflow==1.15
%tensorflow_version 1.x
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.