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.SubsetRandomSampler.rst 981 B

123456789101112131415161718192021222324252627
  1. mindspore.dataset.SubsetRandomSampler
  2. ======================================
  3. .. py:class:: mindspore.dataset.SubsetRandomSampler(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, 7, 88, 119]
  10. >>>
  11. >>> # 创建一个SubsetRandomSampler,从提供的索引中采样
  12. >>> sampler = ds.SubsetRandomSampler(indices)
  13. >>> data = ds.ImageFolderDataset(image_folder_dataset_dir, num_parallel_workers=8, sampler=sampler)
  14. **异常:**
  15. - **TypeError:** `indices` 的类型不是数字。
  16. - **TypeError:** `num_samples` 不是整数值。
  17. - **ValueError:** `num_samples` 为负值。
  18. .. include:: mindspore.dataset.BuiltinSampler.rst