Returns the type specification of an element of a `Dataset` or `Iterator`. Args: dataset_or_iterator: A `tf.data.Dataset` or `tf.data.Iterator`. Returns: A nested structure of `tf.TypeSpec` objects matching the structure of an element of `dataset_or_iterator` and spacifying the typ
(dataset_or_iterator)
| 2213 | |
| 2214 | @tf_export("data.experimental.get_structure") |
| 2215 | def get_structure(dataset_or_iterator): |
| 2216 | """Returns the type specification of an element of a `Dataset` or `Iterator`. |
| 2217 | |
| 2218 | Args: |
| 2219 | dataset_or_iterator: A `tf.data.Dataset` or `tf.data.Iterator`. |
| 2220 | |
| 2221 | Returns: |
| 2222 | A nested structure of `tf.TypeSpec` objects matching the structure of an |
| 2223 | element of `dataset_or_iterator` and spacifying the type of individal |
| 2224 | components. |
| 2225 | |
| 2226 | Raises: |
| 2227 | TypeError: If `dataset_or_iterator` is not a `Dataset` or `Iterator` object. |
| 2228 | """ |
| 2229 | try: |
| 2230 | return dataset_or_iterator.element_spec # pylint: disable=protected-access |
| 2231 | except AttributeError: |
| 2232 | raise TypeError("`dataset_or_iterator` must be a Dataset or Iterator " |
| 2233 | "object, but got %s." % type(dataset_or_iterator)) |
| 2234 | |
| 2235 | |
| 2236 | @tf_export(v1=["data.get_output_classes"]) |
no test coverage detected