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>
Возвращает
логическое значение, указывающее, включён ли 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