You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.dataset.SubsetSampler.rst 1.2 kB

1234567891011121314151617181920212223242526272829
  1. mindspore.dataset.SubsetSampler
  2. ====================================
  3. .. py:class:: mindspore.dataset.SubsetSampler(indices, num_samples=None)
  4. 给定样本的索引序列,对数据集采样指定索引的样本。
  5. **参数:**
  6. - **indices** (Iterable): 索引的序列(包括除了string类型的任意Python可迭代对象类型)。
  7. - **num_samples** (int, 可选): 获取的样本数,可用于部分获取采样得到的样本。默认值:None,获取采样到的所有样本。
  8. **异常:**
  9. - **TypeError:** `indices` 的类型不是整数。
  10. - **TypeError:** `num_samples` 不是整数值。
  11. - **ValueError:** `num_samples` 为负值。
  12. **样例:**
  13. >>> indices = [0, 1, 2, 3, 4, 5]
  14. >>>
  15. >>> # 创建SubsetSampler,根据提供的索引序列,对数据集进行采样
  16. >>> sampler = ds.SubsetSampler(indices)
  17. >>> dataset = ds.ImageFolderDataset(image_folder_dataset_dir,
  18. ... num_parallel_workers=8,
  19. ... sampler=sampler)
  20. .. include:: mindspore.dataset.BuiltinSampler.rst