刚开始试了下面这种方法
import tensorflow.compat.v1 as tf
结果这种方法不可行

import tensorflow as tf
tf.compat.v1.disable_eager_execution()
这种方法可行

当然在下面使用v1中的独有的方法的时候依然需要tf.compat.v1

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐