mindspore2022/docs/api/api_python/dataset/mindspore.dataset.PKSampler...

33 lines
1.5 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.dataset.PKSampler
==============================
.. py:class:: mindspore.dataset.PKSampler(num_val, num_class=None, shuffle=False, class_column='label', num_samples=None)
为数据集中的每个P类采样K个元素。
**参数:**
- **num_val** (int): 每个类要采样的元素数量。
- **num_class** (int, optional): 要采样的类数量默认值为None采样所有类。当前不支持指定该参数。
- **shuffle** (bool, optional): 如果为True则class ID将被打乱否则它将不会被打乱默认值为False
- **class_column** (str, optional): 具有MindDataset类标签的列的名称默认值'label')。
- **num_samples** (int, optional): 要采样的样本数默认值为None对所有元素进行采样
**样例:**
>>> # 创建一个PKSampler从每个类中获取3个样本。
>>> sampler = ds.PKSampler(3)
>>> dataset = ds.ImageFolderDataset(image_folder_dataset_dir,
... num_parallel_workers=8,
... sampler=sampler)
**异常:**
- **TypeError** `shuffle` 不是bool值。
- **TypeError** `class_column` 不是str值。
- **TypeError** `num_samples` 不是整数值。
- **NotImplementedError** `num_class` 不为None。
- **RuntimeError** `num_val` 不是正值。
- **ValueError** `num_samples` 为负值。
.. include:: mindspore.dataset.BuiltinSampler.rst