See `unbatch()` for more details.
(self, input_dataset)
| 3929 | """A dataset that splits the elements of its input into multiple elements.""" |
| 3930 | |
| 3931 | def __init__(self, input_dataset): |
| 3932 | """See `unbatch()` for more details.""" |
| 3933 | flat_shapes = input_dataset._flat_shapes # pylint: disable=protected-access |
| 3934 | if any(s.ndims == 0 for s in flat_shapes): |
| 3935 | raise ValueError("Cannot unbatch an input with scalar components.") |
| 3936 | known_batch_dim = tensor_shape.Dimension(None) |
| 3937 | for s in flat_shapes: |
| 3938 | try: |
| 3939 | known_batch_dim = known_batch_dim.merge_with(s[0]) |
| 3940 | except ValueError: |
| 3941 | raise ValueError("Cannot unbatch an input whose components have " |
| 3942 | "different batch sizes.") |
| 3943 | self._input_dataset = input_dataset |
| 3944 | self._structure = nest.map_structure( |
| 3945 | lambda component_spec: component_spec._unbatch(), # pylint: disable=protected-access |
| 3946 | get_structure(input_dataset)) |
| 3947 | variant_tensor = ged_ops.unbatch_dataset( |
| 3948 | self._input_dataset._variant_tensor, # pylint: disable=protected-access |
| 3949 | **self._flat_structure) |
| 3950 | super(_UnbatchDataset, self).__init__(input_dataset, variant_tensor) |
| 3951 | |
| 3952 | @property |
| 3953 | def element_spec(self): |
nothing calls this directly
no test coverage detected