Tensorflow——[AttributeError:module tensorflow no attribute app]解决方案
问题描述
import tensorflow as tf
FLAGS = tf.app.flags.FLAGS
File "E:\CNN\chengxu\SVM-CNN-12.22\lib\network\resnet_cifar.py", line 9, in <module>from lib.config.config import FLAGSFile "E:\CNN\chengxu\SVM-CNN-12.22\lib\config\config.py", line 16, in <module>FLAGS = tf.app.flags.FLAGS
AttributeError: module 'tensorflow' has no attribute 'app'
官方文档
https://tensorflow.google.cn/install?hl=zh_cn
https://github.com/tensorflow/tensorflow/issues/34431
问题分析
Tensorflow版本问题
当使用Tensorflow2.0,而源代码是Tensorflow1.几版本。
解决方案
(1)将import tensorflow as tf 改为import tensorflow.compat.v1 as tf
import tensorflow.compat.v1 as tf
FLAGS = tf.app.flags.FLAGS
(2)用tf.compat.v1.flags替换tf.app.flags
这两种方法都可以。个人推荐第一种。
(3)下载pycharm,选择python版本,在pycharm里面为python创建对应的虚拟环境,如果原来是tensorflow2.0版本卸载掉,安装tensorflow 1.x版本。
记得勾选specific version 才可以安装。
(4)重装Tensorflow
pip3 uninstall tensorflow-gpu#卸载pip3 install --upgrade tensorflow-gpu #安装
参考文章
https://stackoverflow.com/questions/59272234/attributeerror-module-tensorflow-has-no-attribute-app-error
https://blog.csdn.net/qq_24163555/article/details/102954704
https://blog.csdn.net/weixin_41012399/article/details/103654641
https://www.jianshu.com/p/9b801ecc5fe8
Tensorflow——[AttributeError:module tensorflow no attribute app]解决方案相关推荐
- 关于AttributeError: module ‘tensorflow‘ has no attribute ‘io‘解决方案
最近在写深度强化学习相关的论文仿真,发现在pytorch下利用from torch.utils.tensorboard import SummaryWriter导入的writer会出现Attribut ...
- AttributeError: module ‘tensorflow._api.v2.train‘ has no attribute ‘NewCheckpointReader‘解决方案
解决AttributeError: module 'tensorflow._api.v2.train' has no attribute 'NewCheckpointReader' 问题描述: Ten ...
- AttributeError: module ‘tensorflow‘ has no attribute ‘Session‘错误解决
AttributeError: module 'tensorflow' has no attribute 'Session'错误解决 根据网上教程安装tensorflow环境时,最后都会有个测试代码用 ...
- 问题:AttributeError: module 'tensorflow' has no attribute 'gfile'
目录 问题 原因与解决方案 解决方案1 解决方案2 问题 运行如下代码 if not tf.gfile.exists(DATA_DIRECTORY):tf.gfile.makedirs(DATA_DI ...
- AttributeError: module ‘tensorflow‘ has no attribute ‘InteractiveSession‘或 ‘placeholder‘的解决
问题提示: AttributeError: module 'tensorflow' has no attribute 'InteractiveSession' 或者: AttributeError: ...
- 【TensorFlow报错】AttributeError: module 'tensorflow' has no attribute 'merge_all_summaries'
报错提示: cifar10_train.py : AttributeError: module 'tensorflow' has no attribute 'merge_all_summaries' ...
- 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.keras.backend‘ has no attribute ‘get_session‘ 问题
欢迎大家关注笔者,你的关注是我持续更博的最大动力 原创文章,转载告知,盗版必究 解决tensorflow报错:AttributeError: module 'tensorflow.keras.back ...
最新文章
- 一条命令安装Windows Subsystem for Linux
- 10自带sftp服务器_一文讲透FTP和SFTP的区别
- 【Python】自定义排序函数 - 示例
- react获取id_解决React应用界面开发常见痛点(一)业务逻辑与UI分离
- JavaScript的中对象创建和继承原理
- java工程中使用freemarker例子
- linux 文件隐藏权限,linux文件基本权限、默认权限、隐藏权限和ACL权限
- 基于中医药知识图谱智能问答(一)
- Kindle Touch 5.3.7上手使用指南
- HTML网页设计结课作业 榆林子州 HTML5响应式旅游景区网站模板
- 爬虫学习笔记1——爬取糗百段子
- 老王论坛蓝色大屏幕调节亮度
- [微信小程序]--关于对文章浏览量的实现(inc)
- React Native之携程Moles框架
- [Flutter]微信分享并从分享链接跳回APP指定页面
- 机器学习教程 之 SKlearn 中 PCA 算法的运用:人脸识别实例
- PLSQL12.0.7的下载、安装及使用教程
- 拼多多免单券怎么领取 拼多多免单券是真的吗
- JavaScript 基础学习(三)
- 成都榆熙:拼多多店铺装修的作用是什么?
热门文章
- [转]为什么我们不用软件工程?软件工程能帮多大忙?
- linux 内核日志等级,Linux系统中日志级别详情
- html手机pc不同页面,PC端和手机端如何同时生成静态页
- 按照一定策略把网页抓回到搜索引擎服务器的,SEO新手学习:搜索引擎的基本步骤...
- mysql explain insert_MySQL之EXPLAIN 执行计划详解
- 父元素设置overflow: overlay; 或 overflow: scroll; 或 overflow: auto; 如果子元素超出父元素内容,父元素会被子元素超出部分撑大至子元素同样大小
- 第一批鸿蒙系统手机型号,鸿蒙2.0第一批机型名单正式披露!花粉却感叹:华为不够厚道!...
- php 获取发票内容,php – 如何从发票ID获取PayPal交易ID
- dc综合与pt静态时序分析(中文)_小三电系统(PDU+DC+OBC)的技术研究
- 二十三、前端必学Node.js入门