关于TensorFlow 2.0以上版本使用TensorFlow 1.x,出现属性不存在问题等:
举个栗子:
报错:AttributeError: module ‘tensorflow’ has no attribute ‘placeholder’
# 报错代码内容:
x = tf.placeholder()
解决方法:改成如下两行
tf.compat.v1.disable_eager_execution() # tensorflow2.0以上版本必须加这样一句
x = tf.compat.v1.placeholder()
问题即可解决