问题:AttributeError: module 'tensorflow' has no attribute 'gfile'
目录
- 问题
- 原因与解决方案
- 解决方案1
- 解决方案2
问题
运行如下代码
if not tf.gfile.exists(DATA_DIRECTORY):tf.gfile.makedirs(DATA_DIRECTORY)with tf.gfile.GFile(filepath) as f:
会出现如下问题:
AttributeError: module ‘tensorflow’ has no attribute ‘gfile’
原因与解决方案
问题产生的原因:在当前的版本中,gfile已经定义在io包的file_io.py中。
解决方案1
所以只要改为下面的即可:
if not tf.io.gfile.exists(DATA_DIRECTORY):tf.io.gfile.makedirs(DATA_DIRECTORY)with tf.io.gfile.GFile(filepath) as f:
解决方案2
上面代码其实就是判断给定路径下的文件夹是否存在,如果不存在则创建文件夹。
所以可以用python的os.path来处理。
问题:AttributeError: module 'tensorflow' has no attribute 'gfile'相关推荐
- TensorFlow报AttributeError: module tensorflow has no attribute io
错误描述 在使用TensorFlow的models参考的代码训练目标检测模型时候报AttributeError: module 'tensorflow' has no attribute 'io'错误 ...
- AttributeError: module ‘tensorflow‘ has no attribute ‘Session‘错误解决
AttributeError: module 'tensorflow' has no attribute 'Session'错误解决 根据网上教程安装tensorflow环境时,最后都会有个测试代码用 ...
- AttributeError: module 'tensorflow' has no attribute 'random_normal'
执行<TensorFlow实战Google深度学习框架(第2版)>only源代码 CH3 时如下语句报错 batch_size = 8 w1= tf.Variable(tf.random_ ...
- 问题解决——AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘
问题解决--AttributeError: module 'tensorflow' has no attribute 'placeholder' 参考文章: (1)问题解决--AttributeErr ...
- tensorflow版本问题导致的错误AttributeError: module ‘tensorflow‘ has no attribute ‘***‘
问题解决--AttributeError: module 'tensorflow' has no attribute 'placeholder' - yuanyuanWu11 - 博客园 tensor ...
- 成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘
成功解决AttributeError: module 'tensorflow' has no attribute 'placeholder' 目录 解决问题 解决思路 解决方法 T1.降低tensor ...
- 成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘contrib‘
成功解决AttributeError: module 'tensorflow' has no attribute 'contrib' 目录 解决问题 解决思路 解决方法 解决方法
- 成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘get_variable‘
成功解决AttributeError: module 'tensorflow' has no attribute 'get_variable' 目录 解决问题 解决思路 解决方法 解决问题 Attri ...
- 成功解决AttributeError: module tensorflow has no attribute placeholder
成功解决AttributeError: module 'tensorflow' has no attribute 'placeholder' 目录 解决问题 解决思路 解决方法 解决问题 Attrib ...
最新文章
- DELL通过LCD简单的判别服务器的硬件故障
- 使用ConcurrentHashMap一定线程安全?
- 英伟达吞并Arm失败!英美欧盟一齐干涉,老黄还要给孙正义12.5亿美元分手费
- 一文带你学会国产加密算法SM4的vue实现方案
- 决定神经网络迭代次数的两个因素
- 属于c语言高级参数的,c语言可变参数的取值
- `constexpr`和`const`之间的区别?
- 全连接层 时间复杂度_神经网络全连接层(3)
- 【转】ASP.NET MVC 3 Service Location, Part 5: IDependencyResolver
- 拓端tecdat|R语言量化交易RSI策略:使用支持向量机SVM
- java 反编译 重新打包_「反编译apk」一步一步带你反编译apk,并教你修改smali和重新打包 - seo实验室...
- docker-安装、使用centos7镜像
- 请问,非计算机专业,只为软考中级,哪一种最容易过?
- 安卓手机root推荐,导出安卓分区镜像
- RINEX3广播星历中的toc,toe,IODE 及时间规化
- Unity Shader 之 环境光
- Euclid‘s Game(博弈)
- html简繁替换,Web界面简繁体转换
- OBS 卡顿原因 及 优化策略
- H5页面投票怎么制作
热门文章
- MySql报2006error错误的解决方法(数据过大)
- pom.xml错误:org.codehaus.plexus.archiver.jar.Manifest.write(java.io.PrintWriter)的解决方法
- Hexo博客NexT主题美化之顶部加载进度条
- 【WebAPI No.5】Core WebAPI中的自定义格式化
- 系统管理模块_部门管理_设计(映射)本模块中的所有实体并总结设计实体的技巧_懒加载异常问题_树状结构...
- 读取properties文件
- 【unity】拓展自定义编辑器窗口(二)
- 2.0版本的日历控件在ie8显示不全的解决办法
- 【原创视频教程】学生信息管理系统6--学员信息管理(完结篇)
- oracle12c审计功能,oracle 12c开启关闭统一审计