两种方法解决AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘

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

如果后面还要继续用tf2版本,就可以只更改一句代码:
data_in = tf.compat.v1.placeholder(tf.float32, [None, 100, 100, 3])

猜你喜欢

转载自blog.csdn.net/qq_41754907/article/details/112537107