tensorflow的版本是1.14.0
下边这句报错
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 FLAGS
File "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'
用网上说的解决办法:
(1)将import tensorflow as tf 改为import tensorflow.compat.v1 as tf
(2)用tf.compat.v1.flags替换tf.app.flags
都没用
最后把tensorflow先升级到2.0.0。pip install --upgrade tensorflow==2.0.0
再改成
import tensorflow.compat.v1 as tf
FLAGS = tf.app.flags.FLAGS
成功了。
来源:CSDN
作者:weixin_41012399
链接:https://blog.csdn.net/weixin_41012399/article/details/103654641