在TensorFlow2.x中执行TensorFlow1.x代码的静态图执行模式 改为图执行模式 TensorFlow2虽然和TensorFlow1.x有较大差异,不能直接兼容。但实际上还是提供了对TensorFlow1.x的API支持 TensorFlow 2中执行或开发TensorFlow1.x代码,可以做如下处理: 导入TensorFlow时使用 import tensorflow.compat.v1 as tf禁用即时执行模式 tf.disable_eager_execution()简单两步即可 举例 im……