简体   繁体   English

仍然得到 AttributeError: module 'tensorflow' has no attribute 'gfile' 在尝试了每件事来解决这个问题之后

[英]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.GFiletf.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.

相关问题 AttributeError:模块'tensorflow'没有属性'gfile'Tensorflow 2.8.2 - AttributeError: module 'tensorflow' has no attribute 'gfile' Tensorflow 2.8.2 AttributeError:即使在第 131 行将 tf.gfile.* 更改为 tf.io.gfile.*,模块“tensorflow”也没有属性“gfile” - AttributeError: module 'tensorflow' has no attribute 'gfile' even when changed tf.gfile.* to tf.io.gfile.* in line 131 TensorFlow2.0.0 Alpha-模块'tensorflow'没有属性'gfile' - TensorFlow2.0.0 Alpha- module 'tensorflow' has no attribute 'gfile' 为什么 Tensorflow 即使在我更改文件后也没有属性“gfile”? - Why Tensorflow has no attribute 'gfile' even after I changed the file? 出现错误“AttributeError:模块'tensorflow'没有属性'contrib'” - Getting error “AttributeError: module 'tensorflow' has no attribute 'contrib'” 不断收到这个 AttributeError:部分初始化的模块 'schedule' 没有属性 'every' - Keep getting this AttributeError: partially initialized module 'schedule' has no attribute 'every' AttributeError:模块'tensorflow'在更新后没有属性'python'错误 - AttributeError: module 'tensorflow' has no attribute 'python' error after update 如何解决 AttributeError: module has no attribute python - how to solve AttributeError: module has no attribute python label_map_util.load_labelmap 错误:模块“tensorflow”没有属性“gfile” - label_map_util.load_labelmap Error: module 'tensorflow' has no attribute 'gfile' AttributeError: 模块“tensorflow”没有属性“InteractiveSession” - AttributeError: module 'tensorflow' has no attribute 'InteractiveSession'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM