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

TensorFlow 2.0 version View source on GitHub

Class Structure

Represents structural information, such as type and shape, about a value.


  • Class
  • Class

A Structure generalizes the tf.Tensor.dtype and tf.Tensor.shape properties, so that we can define generic containers of objects including:

TODO(b/110122868): In the future, a single Structure will replace the,, and, and similar properties and arguments in the and Optional classes.



View source


Returns the this structure and the input structure are equal.


  • other: the structure to use for equality check


True if this and the input structure are equal and False otherwise.


View source



View source


Returns a Structure that represents the given value.


  • value: A potentially structured value.


A Structure that is compatible with value.


  • TypeError: If a structure cannot be built for value, because its type or one of its component types is not supported.


View source


Returns True if other is compatible with this structure.

A structure t is a "subtype" of s if:

  • s and t are instances of the same Structure subclass.
  • The nested structures (if any) of s and t are the same, according to tf.nest.assert_same_structure, and each nested structure of t is a "subtype" of the corresponding nested structure of s.
  • Any tf.DType components of t are the same as the corresponding components in s.
  • Any tf.TensorShape components of t are compatible with the corresponding components in s, according to tf.TensorShape.is_compatible_with.


  • other: A Structure.


True if other is a subtype of this structure, otherwise False.