Class Structure
Defined in tensorflow/python/data/util/structure.py.
Represents structural information, such as type and shape, about a value.
A Structure generalizes the tf.Tensor.dtype and tf.Tensor.shape
properties, so that we can define generic containers of objects including:
tf.Tensortf.SparseTensor- Nested structures of the above.
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.data.Iterator and Optional classes.
Methods
tf.data.experimental.Structure.from_value
@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 forvalue, because its type or one of its component types is not supported.
tf.data.experimental.Structure.is_compatible_with
is_compatible_with(other)
Returns True if other is compatible with this structure.
A structure t is a "subtype" of s if:
sandtare instances of the sameStructuresubclass.- The nested structures (if any) of
sandtare the same, according totf.contrib.framework.nest.assert_same_structure, and each nested structure oftis a "subtype" of the corresponding nested structure ofs. - Any
tf.DTypecomponents oftare the same as the corresponding components ins. - Any
tf.TensorShapecomponents oftare compatible with the corresponding components ins, according totf.TensorShape.is_compatible_with.
Args:
other: AStructure.
Returns:
True if other is a subtype of this structure, otherwise False.