mindspore.dataset.text.transforms.SlidingWindow
- class mindspore.dataset.text.transforms.SlidingWindow(width, axis=0)[source]
TensorOp to construct a tensor from data (only 1-D for now), where each element in the dimension axis is a slice of data starting at the corresponding position, with a specified width.
- Parameters
Examples
>>> dataset = ds.NumpySlicesDataset(data=[[1, 2, 3, 4, 5]], column_names="col1") >>> # Data before >>> # | col1 | >>> # +--------------+ >>> # | [[1, 2, 3, 4, 5]] | >>> # +--------------+ >>> dataset = dataset.map(operations=text.SlidingWindow(3, 0)) >>> # Data after >>> # | col1 | >>> # +--------------+ >>> # | [[1, 2, 3], | >>> # | [2, 3, 4], | >>> # | [3, 4, 5]] | >>> # +--------------+