tensorflow版本问题导致的错误AttributeError: module ‘tensorflow‘ has no attribute ‘***‘

1.异常

2.原因:当你安装的tf的版本是2.0,但是你却在使用tf1.0的API,就会导致这样的错误。2.0是不支持1.0的。

3.解决

将:

import tensorflow as tf

改为:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

这样就行了

猜你喜欢

转载自blog.csdn.net/a_cherry_blossoms/article/details/113953481