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.0 kB

1234567891011121314151617181920212223242526272829
  1. mindspore.dataset.SequentialSampler
  2. ====================================
  3. .. py:class:: mindspore.dataset.SubsetSampler(indices, num_samples=None)
  4. 对索引序列中的元素进行采样。
  5. **参数:**
  6. - **indices** (Any iterable Python object but string): 索引的序列。
  7. - **num_samples** (int, optional): 要采样的元素数量(默认值为None,采样所有元素)。
  8. **样例:**
  9. >>> indices = [0, 1, 2, 3, 4, 5]
  10. >>>
  11. >>> # 创建SubsetSampler,从提供的索引采样
  12. >>> sampler = ds.SubsetSampler(indices)
  13. >>> dataset = ds.ImageFolderDataset(image_folder_dataset_dir,
  14. ... num_parallel_workers=8,
  15. ... sampler=sampler)
  16. **异常:**
  17. - **TypeError:** 索引元素的类型不是数字。
  18. - **TypeError:** `num_samples` 不是整数值。
  19. - **ValueError:** `num_samples` 为负值。
  20. .. include:: mindspore.dataset.BuiltinSampler.rst