mindspore.dataset.transforms.Slice
- class mindspore.dataset.transforms.Slice(*slices)[源代码]
使用给定的slices,对Tensor进行切片操作。功能类似于NumPy的索引(目前只支持1D形状的Tensor)。
- 参数:
- 异常:
- 支持平台:
CPU
样例:
>>> # Data before >>> # | col | >>> # +---------+ >>> # | [1,2,3] | >>> # +---------| >>> data = [[1, 2, 3]] >>> numpy_slices_dataset = ds.NumpySlicesDataset(data, ["col"]) >>> # slice indices 1 and 2 only >>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms.Slice(slice(1,3))) >>> # Data after >>> # | col | >>> # +---------+ >>> # | [2,3] | >>> # +---------|