mindspore.dataset.MappableDataset.use_sampler

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

>>> # dataset is an instance object of Dataset
>>> # use a DistributedSampler instead
>>> new_sampler = ds.DistributedSampler(10, 2)
>>> dataset.use_sampler(new_sampler)