Я предполагаю, что вы используете TensorFlow 2.0.В TF2 режим ожидания включен по умолчанию.Однако в TensorFlow 2.0.0-alpha0 есть disable_eager_execution()
, но он скрыт довольно глубоко и не может быть напрямую доступен из пространства имен модуля верхнего уровня (т. Е. Пространства имен tf).
Вы можете вызвать функцию какитак:
import tensorflow as tf
from tensorflow.python.framework.ops import disable_eager_execution
disable_eager_execution()
a = tf.constant(1)
b = tf.constant(2)
c = a + b
print(c)
>>>Tensor("add:0", shape=(), dtype=int32)
print(disable_eager_execution.__doc__)
>>>Disables eager execution.
This function can only be called before any Graphs, Ops, or Tensors have been created. It can be used at the beginning of the program for complex migration projects from TensorFlow 1.x to 2.x.