tensorflow报错AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘

代码开头加入代码

tensorflow2下使用tensorflow1的方法

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

代码开头加入代码

tensorflow1下使用tensorflow2的方法

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

你可能感兴趣的:(tensorflow,深度学习,python,人工智能)