Watch talks from the 2019 TensorFlow Dev Summit Watch now

tff.utils.identity

tff.utils.identity(source)

Defined in core/utils/tf_computation_utils.py.

Applies tf.identity pointwise to 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.contrib.framework.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.