mindspore.dataset.MappableDataset.use_sampler

mindspore.dataset.MappableDataset.use_sampler(new_sampler)[源代码]

替换当前数据集的最末子采样器,保持父采样器不变。

参数:
  • new_sampler (Sampler) - 用于替换的新采样器。

样例:

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