原因:在TensorFlow中,tf.placeholder()与动态执行(eager execution)是不兼容的。 解决办法1:使用 tf.keras.Input() 函数创建的占位符 解决办法2:在调用创建占位符函数时添加以下代码 tf.compat.v1.disable_eager_execution() TensorFlow 2.x 中的函数,用于在 Eager Execution 模式下切换回 TensorFlow 1.x 的图执行模式。