Spec-Zone.ru › TensorFlow

tf.compat.v1.executing_eagerly_outside_functions

Возвращает True, если выполнение происходит в режиме eager, даже если внутри функции графа.

tf.compat.v1.executing_eagerly_outside_functions() -> bool

Эта функция проверяет внешний контекст программы и определяет, находится ли она в режиме eager. Она полезна для сравнения с tf.executing_eagerly(), которая проверяет текущий контекст и вернёт False внутри тела tf.function. Её можно использовать для создания библиотек, которые ведут себя по-разному в режиме eager и режиме сессии v1 (устаревшая).

Пример:

tf.compat.v1.enable_eager_execution()
@tf.function
def func():
  # A function constructs TensorFlow graphs, it does not execute eagerly,
  # but the outer most context is still eager.
  assert not tf.executing_eagerly()
  return tf.compat.v1.executing_eagerly_outside_functions()
func()
<tf.Tensor: shape=(), dtype=bool, numpy=True>
Возвращает
boolean, является ли внешний контекст в режиме eager.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/compat/v1/executing_eagerly_outside_functions

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API