[英]AttributeError: module 'tensorflow' has no attribute 'gfile' Tensorflow 2.8.2
can someone please help me with this error....I tried using tf.io.gfile instead of tf.gfile then to its not working有人可以帮我解决这个错误....我尝试使用 tf.io.gfile 而不是 tf.gfile 然后它不起作用
error shown is still the same显示的错误仍然相同
AttributeError: module 'tensorflow' has no attribute 'gfile' AttributeError:模块“tensorflow”没有属性“gfile”
tf.gfile is now submodule of tf.io , which you can use by giving an updated full alias name tf.io.gfile.GFile . tf.gfile现在是tf.io的子模块,您可以通过提供更新的完整别名tf.io.gfile.GFile来使用它。
Please check below code for your reference:请检查以下代码以供参考:
import tensorflow as tf
print(tf.__version__)
with open("/tmp/x", "w") as f:
print(f.write("asdf"))
with tf.io.gfile.GFile("/tmp/x") as f: # <----using tf.io.gfile.GFile
print(f.read())
Output:输出:
2.8.2
4
asdf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.