AttributeError:module tensorflow no attribute app,以及module 'tensorflow' has no attribute 'flags'等等

AttributeError:module tensorflow no attribute app,以及module 'tensorflow' has no attribute 'flags'等等_第1张图片
这是因为tensorflow版本的原因,我的tensorflow的版本是2.0.0的,而源代码是tensorflow1.几版本的,所以只需要将源文件里面的

  • import tensorflow ad tf 改为 import tensorflow.compat.v1 as tf
    具体方法:编辑你的文件
    在这里插入图片描述
    AttributeError:module tensorflow no attribute app,以及module 'tensorflow' has no attribute 'flags'等等_第2张图片

最后成功
AttributeError:module tensorflow no attribute app,以及module 'tensorflow' has no attribute 'flags'等等_第3张图片

跑代码还遇到这个问题
在这里插入图片描述tf.placeholder()is not compatible with eager execution。此时需要在引入的import tensorflow.compat.v1 as tf下面添加一行

tf.disable_v2_behavior()

如下图所示在这里插入图片描述

你可能感兴趣的:(code问题记录)