Join us at TensorFlow World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tff.utils.identity

View source

Applies tf.identity pointwise to source.

tff.utils.identity(source)

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.