mindspore/docs/api/api_python/dataset/mindspore.dataset.Distribut...

28 lines
1.6 KiB
ReStructuredText
Raw Normal View History

2021-11-26 19:07:07 +08:00
mindspore.dataset.DistributedSampler
====================================
.. py:class:: mindspore.dataset.DistributedSampler(num_shards, shard_id, shuffle=True, num_samples=None, offset=-1)
2021-11-23 15:00:48 +08:00
分布式采样器,将数据集进行分片用于分布式训练。
**参数:**
2021-11-26 19:07:07 +08:00
2021-12-04 20:36:47 +08:00
- **num_shards** (int) - 数据集分片数量。
- **shard_id** (int) - 当前分片的分片ID应在[0, num_shards-1]范围内。
2022-01-05 16:22:27 +08:00
- **shuffle** (bool, 可选) - 是否混洗采样得到的样本默认值True混洗样本。
- **num_samples** (int, 可选) - 获取的样本数可用于部分获取采样得到的样本默认值None获取采样到的所有样本。
- **offset** (int, 可选) - 分布式采样结果进行分配时的起始分片ID号值不能大于参数 `num_shards` 。从不同的分片ID开始分配数据可能会影响每个分片的最终样本数。仅当ConcatDataset以DistributedSampler为采样器时此参数才有效。默认值-1每个分片具有相同的样本数。
2021-11-23 15:00:48 +08:00
**异常:**
2021-11-26 19:07:07 +08:00
2021-12-04 20:36:47 +08:00
- **TypeError** - `num_shards` 不是整数值。
- **TypeError** - `shard_id` 不是整数值。
- **TypeError** - `shuffle` 不是Boolean值。
- **TypeError** - `num_samples` 不是整数值。
- **TypeError** - `offset` 不是整数值。
- **ValueError** - `num_samples` 为负值。
- **RuntimeError** - `num_shards` 不是正值。
- **RuntimeError** - `shard_id` 小于0或大于等于 `num_shards`
- **RuntimeError** - `offset` 大于 `num_shards`
2021-11-23 15:00:48 +08:00
.. include:: mindspore.dataset.BuiltinSampler.rst