AttributeError: module 'tensorflow' has no attribute 'app'
tensorflow的版本是1.14.0下边这句报错import tensorflow as tfFLAGS = tf.app.flags.FLAGSFile "E:\CNN\chengxu\SVM-CNN-12.22\lib\network\resnet_cifar.py", line 9, in <module>from lib.config.conf...
·
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
成功了。
更多推荐
已为社区贡献5条内容
所有评论(0)