module 'tensorflow' has no attribute 'placeholder'

我用的是tensorflow 2.0 ,所以用了import tensorflow as tf 就出现了这个错误:module ‘tensorflow’ has no attribute ‘placeholder’

把import tensorflow as tf 替换为:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
就可以了

发布了34 篇原创文章 · 获赞 4 · 访问量 1559

猜你喜欢

转载自blog.csdn.net/qq_36495569/article/details/103328399