tensorflow2.0默认是Eager execution模式,为什么要用这个模式呢?
开启这个模式以后:
1.numpy的操作可以接受Tensor作为参数(一般情况下,python和numpy的arrays会被转换成Tensor)
2.一切皆函数,无须手动搭建tensorflow数据结构
状态查看代码
tf.compat.v1.executing_eagerly()
关闭与启动eager模式
关闭:
tf.compat.v1.disable_eager_execution()
开启:
tf.compat.v1.enable_eager_execution()