mindspore.dataset.MappableDataset.use_sampler

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

Replace the last child sampler of the current dataset, remaining the parent sampler unchanged.

Parameters

new_sampler (Sampler) – The new sampler to replace with.

Examples

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