TensorFlow 2.0 Beta is available Learn more

tf.data.experimental.Structure

Class Structure

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

Aliases:

  • Class tf.compat.v1.data.experimental.Structure
  • Class tf.compat.v2.data.experimental.Structure
  • Class tf.data.experimental.Structure
View source on GitHub

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 tf.data.Dataset.output_types, tf.data.Dataset.output_shapes, and tf.data.Dataset.output_classes, and similar properties and arguments in the tf.compat.v1.data.Iterator and Optional classes.

Methods

__eq__

View source

__eq__(other)

Returns the this structure and the input structure are equal.

Args:

  • other: the structure to use for equality check

Returns:

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

__ne__

View source

__ne__(other)

from_value

View source

@staticmethod
from_value(value)

Returns a Structure that represents the given value.

Args:

  • value: A potentially structured value.

Returns:

A Structure that is compatible with value.

Raises:

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

is_compatible_with

View source

is_compatible_with(other)

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.

Args:

  • other: A Structure.

Returns:

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