TensorFlow 2.0 Beta is available Learn more

tff.utils.identity

Applies tf.identity pointwise to source.

tff.utils.identity(source)

Defined in python/core/utils/tf_computation_utils.py.

This utility function provides the exact same behavior as tf.identity, but it generalizes to a wider class of objects, including ordinary tensors, variables, as well as various types of nested structures. It would typically be used together with tf.control_dependencies in non-eager TensorFlow.

Args:

  • source: A nested structure composed of tensors or variables embedded in containers that are compatible with tf.nest, or instances of anonymous_tuple.AnonymousTuple. Elements that represent variables have their content extracted prior to identity mapping by first invoking tf.Variable.read_value.

Returns:

The result of applying tf.identity to read all elements of the source pointwise, with the same structure as source.

Raises:

  • TypeError: If types mismatch.