Returns the type signature for elements of the input dataset / iterator.
tf.data.experimental.get_structure(
dataset_or_iterator
)
For example, to get the structure of a tf.data.Dataset:
dataset = tf.data.Dataset.from_tensor_slices([1, 2, 3]) tf.data.experimental.get_structure(dataset) TensorSpec(shape=(), dtype=tf.int32, name=None)
dataset = tf.data.experimental.from_list([(1, 'a'), (2, 'b'), (3, 'c')]) tf.data.experimental.get_structure(dataset) (TensorSpec(shape=(), dtype=tf.int32, name=None), TensorSpec(shape=(), dtype=tf.string, name=None))
To get the structure of an tf.data.Iterator:
dataset = tf.data.Dataset.from_tensor_slices([1, 2, 3]) tf.data.experimental.get_structure(iter(dataset)) TensorSpec(shape=(), dtype=tf.int32, name=None)
| Args | |
|---|---|
dataset_or_iterator | A tf.data.Dataset or an tf.data.Iterator. |
| Returns | |
|---|---|
A (nested) structure of tf.TypeSpec objects matching the structure of an element of dataset_or_iterator and specifying the type of individual components. |
| Raises | |
|---|---|
TypeError | If input is not a tf.data.Dataset or an tf.data.Iterator object. |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/data/experimental/get_structure