See `Dataset.from_tensor_slices()` for details.
(self, element)
| 2465 | """A `Dataset` of slices from a dataset element.""" |
| 2466 | |
| 2467 | def __init__(self, element): |
| 2468 | """See `Dataset.from_tensor_slices()` for details.""" |
| 2469 | element = structure.normalize_element(element) |
| 2470 | batched_spec = structure.type_spec_from_value(element) |
| 2471 | self._tensors = structure.to_batched_tensor_list(batched_spec, element) |
| 2472 | self._structure = nest.map_structure( |
| 2473 | lambda component_spec: component_spec._unbatch(), batched_spec) # pylint: disable=protected-access |
| 2474 | |
| 2475 | batch_dim = tensor_shape.Dimension(tensor_shape.dimension_value( |
| 2476 | self._tensors[0].get_shape()[0])) |
| 2477 | for t in self._tensors[1:]: |
| 2478 | batch_dim.assert_is_compatible_with(tensor_shape.Dimension( |
| 2479 | tensor_shape.dimension_value(t.get_shape()[0]))) |
| 2480 | |
| 2481 | variant_tensor = gen_dataset_ops.tensor_slice_dataset( |
| 2482 | self._tensors, |
| 2483 | output_shapes=structure.get_flat_tensor_shapes(self._structure)) |
| 2484 | super(TensorSliceDataset, self).__init__(variant_tensor) |
| 2485 | |
| 2486 | @property |
| 2487 | def element_spec(self): |
nothing calls this directly
no test coverage detected