mindspore.dataset.MappableDataset.add_sampler

View Source On Gitee
MappableDataset.add_sampler(new_sampler)[source]

Add a child sampler for the current dataset.

Note

  • If the sampler is added and it has a shuffle option, its value must be Shuffle.GLOBAL . Additionally, the original sampler's shuffle value cannot be Shuffle.PARTIAL .

Parameters

new_sampler (Sampler) – The child sampler to be added.

Examples

>>> import mindspore.dataset as ds
>>> dataset = ds.GeneratorDataset([i for i in range(10)], "column1")
>>>
>>> new_sampler = ds.DistributedSampler(10, 2)
>>> dataset.add_sampler(new_sampler)