mindspore.dataset.MappableDataset.add_sampler
- mindspore.dataset.MappableDataset.add_sampler(new_sampler)[源代码]
为当前数据集添加子采样器。
说明
被添加的sampler如果有 shuffle 属性,其值必须是
Shuffle.GLOBAL
,且原sampler的 shuffle 属性值不能是Shuffle.PARTIAL
。- 参数:
new_sampler (Sampler) - 待添加的子采样器。
样例:
>>> 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)