且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何禁用 TensorFlow 的急切执行?

更新时间:2023-01-23 14:55:38

假设您使用的是 Tensorflow 2.0 预览版,它默认启用了 Eager Execution.v1 API 中有一个 disable_eager_execution(),你可以把它放在你的代码前面,比如:

Assume you are using Tensorflow 2.0 preview release which has eager execution enabled by default. There is a disable_eager_execution() in v1 API, which you can put in the front of your code like:

import tensorflow as tf

tf.compat.v1.disable_eager_execution()

另一方面,如果您没有使用 2.0 预览版,请检查您是否不小心在某处启用了 Eager Execution.

On the other hand, if you are not using 2.0 preview, please check if you accidentally enabled eager execution somewhere.