!30006 update minddata chinese api

Merge pull request !30006 from luoyang/code_docs_chinese
This commit is contained in:
i-robot 2022-02-17 07:01:17 +00:00 committed by Gitee
commit 548283ed6e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
56 changed files with 1450 additions and 42 deletions

View File

@ -0,0 +1,123 @@
mindspore.dataset.Caltech101Dataset
===================================
.. py:class:: mindspore.dataset.Caltech101Dataset(dataset_dir, target_type=None, num_samples=None, num_parallel_workers=1, shuffle=None, decode=False, sampler=None, num_shards=None, shard_id=None)
读取和解析Caltech101数据集的源文件构建数据集。
根据不同的 `target_type` 配置,数据集会生成不同的输出列。
- `target_type` = 'category',输出列为 `[image, category]`
- `target_type` = 'annotation',输出列为 `[image, annotation]`
- `target_type` = 'all',输出列为 `[image, category, annotation]`
列 'image' 为 uint8 类型,列 'category' 为 uint32 类型,列 'annotation' 是一个二维的ndarray存储了图像的轮廓由一系列的点组成。
**参数:**
- **dataset_dir** (str) - 包含数据集文件的根目录路径该路径下将包含2个子目录目录101_ObjectCategories用于存储图像
目录Annotations用于存储图像的标注。
- **target_type** (str, 可选) - 指定数据集的子集,可取值为'category'、'annotation' 或 'all'。
取值为'category'时将读取图像的类别标注作为label取值为'annotation'时将读取图像的轮廓标注作为label
取值为'all'时将同时输出图像的类别标注和轮廓标注。默认值:'category'。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数可以小于数据集总数。默认值None读取全部样本图片。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值None使用mindspore.dataset.config中配置的线程数。
- **shuffle** (bool, 可选) - 是否混洗数据集。默认值None下表中会展示不同参数配置的预期行为。
- **decode** (bool, 可选) - 是否对读取的图片进行解码操作默认值False不解码。
- **sampler** (Sampler, 可选) - 指定从数据集中选取样本的采样器默认值None下表中会展示不同配置的预期行为。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数默认值None。指定此参数后 `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号默认值None。只有当指定了 `num_shards` 时才能指定此参数。
**异常:**
- **RuntimeError** - `dataset_dir` 路径下不包含任何数据文件。
- **ValueError** - `target_type` 参数取值不为'category'、'annotation'或'all'。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 同时指定了 `sampler``shuffle` 参数。
- **RuntimeError** - 同时指定了 `sampler``num_shards` 参数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数值错误小于0或者大于等于 `num_shards` )。
.. note:: 此数据集可以指定参数 `sampler` ,但参数 `sampler` 和参数 `shuffle` 的行为是互斥的。下表展示了几种合法的输入参数组合及预期的行为。
.. list-table:: 配置 `sampler``shuffle` 的不同组合得到的预期排序结果
:widths: 25 25 50
:header-rows: 1
* - 参数 `sampler`
- 参数 `shuffle`
- 预期数据顺序
* - None
- None
- 随机排列
* - None
- True
- 随机排列
* - None
- False
- 顺序排列
* - `sampler` 实例
- None
- 由 `sampler` 行为定义的顺序
* - `sampler` 实例
- True
- 不允许
* - `sampler` 实例
- False
- 不允许
**关于Caltech101数据集**
Caltech101数据集包含 101 种类别的图片,每种类别大约 40 到 800 张图像,大多数类别有大约 50 张图像。
每张图像的大小约为 300 x 200 像素。数据集中也提供了每张图片中每个物体的轮廓数据,用于检测和定位。
您可以解压缩原始Caltech101数据集文件到如下目录结构并通过MindSpore的API进行读取。
.. code-block::
.
└── caltech101_dataset_directory
├── 101_ObjectCategories
│ ├── Faces
│ │ ├── image_0001.jpg
│ │ ├── image_0002.jpg
│ │ ...
│ ├── Faces_easy
│ │ ├── image_0001.jpg
│ │ ├── image_0002.jpg
│ │ ...
│ ├── ...
└── Annotations
├── Airplanes_Side_2
│ ├── annotation_0001.mat
│ ├── annotation_0002.mat
│ ...
├── Faces_2
│ ├── annotation_0001.mat
│ ├── annotation_0002.mat
│ ...
├── ...
**引用:**
.. code-block::
@article{FeiFei2004LearningGV,
author = {Li Fei-Fei and Rob Fergus and Pietro Perona},
title = {Learning Generative Visual Models from Few Training Examples:
An Incremental Bayesian Approach Tested on 101 Object Categories},
journal = {Computer Vision and Pattern Recognition Workshop},
year = {2004},
url = {http://www.vision.caltech.edu/Image_Datasets/Caltech101/},
}
.. include:: mindspore.dataset.Dataset.add_sampler.rst
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.use_sampler.rst
.. include:: mindspore.dataset.Dataset.zip.rst

View File

@ -0,0 +1,110 @@
mindspore.dataset.Caltech256Dataset
===================================
.. py:class:: mindspore.dataset.Caltech256Dataset(dataset_dir, num_samples=None, num_parallel_workers=None, shuffle=None, decode=False, sampler=None, num_shards=None, shard_id=None, cache=None)
读取和解析Caltech256数据集的源文件构建数据集。
生成的数据集有两列 `[image, label]``image` 列的数据类型为uint8。`label` 列的数据类型为uint32。
**参数:**
- **dataset_dir** (str) - 包含数据集文件的根目录路径。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数可以小于数据集总数。默认值None读取全部样本图片。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值None使用mindspore.dataset.config中配置的线程数。
- **shuffle** (bool, 可选) - 是否混洗数据集。默认值None下表中会展示不同参数配置的预期行为。
- **decode** (bool, 可选) - 是否对读取的图片进行解码操作默认值False不解码。
- **sampler** (Sampler, 可选) - 指定从数据集中选取样本的采样器默认值None下表中会展示不同配置的预期行为。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数默认值None。指定此参数后 `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号默认值None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/docs/programming_guide/zh-CN/master/cache.html>`_ 。默认值None不使用缓存。
**异常:**
- **RuntimeError** - `dataset_dir` 路径下不包含任何数据文件。
- **ValueError** - `target_type` 参数取值不为'category'、'annotation'或'all'。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 同时指定了 `sampler``shuffle` 参数。
- **RuntimeError** - 同时指定了 `sampler``num_shards` 参数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数值错误小于0或者大于等于 `num_shards` )。
.. note:: 此数据集可以指定参数 `sampler` ,但参数 `sampler` 和参数 `shuffle` 的行为是互斥的。下表展示了几种合法的输入参数组合及预期的行为。
.. list-table:: 配置 `sampler``shuffle` 的不同组合得到的预期排序结果
:widths: 25 25 50
:header-rows: 1
* - 参数 `sampler`
- 参数 `shuffle`
- 预期数据顺序
* - None
- None
- 随机排列
* - None
- True
- 随机排列
* - None
- False
- 顺序排列
* - `sampler` 实例
- None
- 由 `sampler` 行为定义的顺序
* - `sampler` 实例
- True
- 不允许
* - `sampler` 实例
- False
- 不允许
**关于Caltech256数据集**
Caltech-256 是一个对象识别数据集,包含 30,607 张不同大小的真实世界图像,共有 257 个类别256类物体和1个其他类
每个类别由至少 80 张图像。该数据集是 Caltech101 数据集的超集。
您可以解压缩原始Caltech256数据集文件到如下目录结构并通过MindSpore的API进行读取。
.. code-block::
.
└── caltech256_dataset_directory
├── 001.ak47
│ ├── 001_0001.jpg
│ ├── 001_0002.jpg
│ ...
├── 002.american-flag
│ ├── 002_0001.jpg
│ ├── 002_0002.jpg
│ ...
├── 003.backpack
│ ├── 003_0001.jpg
│ ├── 003_0002.jpg
│ ...
├── ...
**引用:**
.. code-block::
@article{griffin2007caltech,
title = {Caltech-256 object category dataset},
added-at = {2021-01-21T02:54:42.000+0100},
author = {Griffin, Gregory and Holub, Alex and Perona, Pietro},
biburl = {https://www.bibsonomy.org/bibtex/21f746f23ff0307826cca3e3be45f8de7/s364315},
interhash = {bfe1e648c1778c04baa60f23d1223375},
intrahash = {1f746f23ff0307826cca3e3be45f8de7},
publisher = {California Institute of Technology},
timestamp = {2021-01-21T02:54:42.000+0100},
year = {2007}
}
.. include:: mindspore.dataset.Dataset.add_sampler.rst
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.use_sampler.rst
.. include:: mindspore.dataset.Dataset.zip.rst

View File

@ -0,0 +1,135 @@
mindspore.dataset.CityscapesDataset
===================================
.. py:class:: mindspore.dataset.CityscapesDataset(dataset_dir, usage="train", quality_mode="fine", task="instance", num_samples=None, num_parallel_workers=None, shuffle=None, decode=None, sampler=None, num_shards=None, shard_id=None, cache=None)
读取和解析Cityscapes数据集的源文件构建数据集。
生成的数据集有两列 `[image, task]`
`image` 列的数据类型为uint8。`task` 列的数据类型根据参数 `task` 的值而定,当 参数 `task` 取值为'polygon'列的数据类型为string其他取值下列的数据类型为uint8。
**参数:**
- **dataset_dir** (str) - 包含数据集文件的根目录路径。
- **usage** (str, 可选) - 指定数据集的子集。当参数 `quality_mode` 取值为'fine'时,此参数可取值为'train'、'test'、'val'或'all'。
在参数 `quality_mode` 的其他取值下,此参数可取值为'train'、'train_extra'、'val'或'all'。默认值:'train',全部样本图片。
- **quality_mode** (str, 可选) - 指定数据集的质量模式,可取值为'fine'或'coarse'。默认值:'fine'。
- **task** (str, 可选) - 指定数据集的任务类型,可取值为'instance'、'semantic'、'polygon'或'color'。默认值:'instance'。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数可以小于数据集总数。默认值None读取全部样本图片。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值None使用mindspore.dataset.config中配置的线程数。
- **shuffle** (bool, 可选) - 是否混洗数据集。默认值None下表中会展示不同参数配置的预期行为。
- **decode** (bool, 可选) - 是否对读取的图片进行解码操作默认值False不解码。
- **sampler** (Sampler, 可选) - 指定从数据集中选取样本的采样器默认值None下表中会展示不同配置的预期行为。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数默认值None。指定此参数后 `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号默认值None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/docs/programming_guide/zh-CN/master/cache.html>`_ 。默认值None不使用缓存。
**异常:**
- **RuntimeError** - `dataset_dir` 路径下不包含任何数据文件。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 同时指定了 `sampler``shuffle` 参数。
- **RuntimeError** - 同时指定了 `sampler``num_shards` 参数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `dataset_dir` 路径非法或不存在。
- **ValueError** - `task` 参数取值不为'instance'、'semantic'、'polygon'或'color'。
- **ValueError** - `quality_mode` 参数取值不为'fine'或'coarse'。
- **ValueError** - `usage` 参数取值不在给定的字段中。
- **ValueError** - `shard_id` 参数值错误小于0或者大于等于 `num_shards` )。
.. note:: 此数据集可以指定参数 `sampler` ,但参数 `sampler` 和参数 `shuffle` 的行为是互斥的。下表展示了几种合法的输入参数组合及预期的行为。
.. list-table:: 配置 `sampler``shuffle` 的不同组合得到的预期排序结果
:widths: 25 25 50
:header-rows: 1
* - 参数 `sampler`
- 参数 `shuffle`
- 预期数据顺序
* - None
- None
- 随机排列
* - None
- True
- 随机排列
* - None
- False
- 顺序排列
* - `sampler` 实例
- None
- 由 `sampler` 行为定义的顺序
* - `sampler` 实例
- True
- 不允许
* - `sampler` 实例
- False
- 不允许
**关于Cityscapes数据集**
Cityscapes 数据集由来自 50 个城市的 24998 张彩色图像组成。
其中 5000 张图像具有高质量的密集像素标注, 19998 张图像具有粗糙的多边形标注。
该数据集共有 30 个类,多边形标注包括密集语义分割,以及车辆和人的实例分割。
您可以解压缩原始Caltech256数据集文件到如下目录结构并通过MindSpore的API进行读取。
.. code-block::
.
└── Cityscapes
├── leftImg8bit
| ├── train
| | ├── aachen
| | | ├── aachen_000000_000019_leftImg8bit.png
| | | ├── aachen_000001_000019_leftImg8bit.png
| | | ├── ...
| | ├── bochum
| | | ├── ...
| | ├── ...
| ├── test
| | ├── ...
| ├── val
| | ├── ...
└── gtFine
├── train
| ├── aachen
| | ├── aachen_000000_000019_gtFine_color.png
| | ├── aachen_000000_000019_gtFine_instanceIds.png
| | ├── aachen_000000_000019_gtFine_labelIds.png
| | ├── aachen_000000_000019_gtFine_polygons.json
| | ├── aachen_000001_000019_gtFine_color.png
| | ├── aachen_000001_000019_gtFine_instanceIds.png
| | ├── aachen_000001_000019_gtFine_labelIds.png
| | ├── aachen_000001_000019_gtFine_polygons.json
| | ├── ...
| ├── bochum
| | ├── ...
| ├── ...
├── test
| ├── ...
└── val
├── ...
**引用:**
.. code-block::
@inproceedings{Cordts2016Cityscapes,
title = {The Cityscapes Dataset for Semantic Urban Scene Understanding},
author = {Cordts, Marius and Omran, Mohamed and Ramos, Sebastian and Rehfeld, Timo and Enzweiler,
Markus and Benenson, Rodrigo and Franke, Uwe and Roth, Stefan and Schiele, Bernt},
booktitle = {Proc. of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2016}
}
.. include:: mindspore.dataset.Dataset.add_sampler.rst
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.use_sampler.rst
.. include:: mindspore.dataset.Dataset.zip.rst

View File

@ -0,0 +1,148 @@
mindspore.dataset.DIV2KDataset
==============================
.. py:class:: mindspore.dataset.DIV2KDataset(dataset_dir, usage="train", downgrade="bicubic", scale=2, num_samples=None, num_parallel_workers=None, shuffle=None, decode=None, sampler=None, num_shards=None, shard_id=None, cache=None)
读取和解析DIV2K数据集的源文件构建数据集。
生成的数据集有两列 `[hr_image, lr_image]` 。'hr_image` 列和 `lr_image` 列的数据类型都为uint8。
**参数:**
- **dataset_dir** (str) - 包含数据集文件的根目录路径。
- **usage** (str, 可选) - 指定数据集的子集。可取值为'train'、'valid'或'all'。默认值:'train',全部样本图片。
- **downgrade** (str, 可选) - 指定数据集的下采样的模式,可取值为'bicubic'、'unknown'、'mild'、'difficult'或'wild'。默认值:'bicubic'。
- **scale** (str, 可选) - 指定数据集的缩放尺度。当参数`downgrade` 取值为'bicubic'时此参数可以取值为2、3、4、8。
当参数`downgrade` 取值为'unknown'时此参数可以取值为2、3、4。当参数`downgrade` 取值为'mild'、'difficult'、'wild'时此参数仅可以取值为4。默认值2。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数可以小于数据集总数。默认值None读取全部样本图片。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值None使用mindspore.dataset.config中配置的线程数。
- **shuffle** (bool, 可选) - 是否混洗数据集。默认值None下表中会展示不同参数配置的预期行为。
- **decode** (bool, 可选) - 是否对读取的图片进行解码操作默认值False不解码。
- **sampler** (Sampler, 可选) - 指定从数据集中选取样本的采样器默认值None下表中会展示不同配置的预期行为。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数默认值None。指定此参数后 `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号默认值None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/docs/programming_guide/zh-CN/master/cache.html>`_ 。默认值None不使用缓存。
**异常:**
- **RuntimeError** - `dataset_dir` 路径下不包含任何数据文件。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 同时指定了 `sampler``shuffle` 参数。
- **RuntimeError** - 同时指定了 `sampler``num_shards` 参数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `dataset_dir` 路径非法或不存在。
- **ValueError** - `usage` 参数取值不为'train'、'valid'或'all'。
- **ValueError** - `downgrade` 参数取值不为'bicubic'、'unknown'、'mild'、'difficult'或'wild'。
- **ValueError** - `scale` 参数取值不在给定的字段中,或与 `downgrade` 参数的值不匹配。
- **ValueError** - `shard_id` 参数值错误小于0或者大于等于 `num_shards` )。
.. note:: 此数据集可以指定参数 `sampler` ,但参数 `sampler` 和参数 `shuffle` 的行为是互斥的。下表展示了几种合法的输入参数组合及预期的行为。
.. list-table:: 配置 `sampler``shuffle` 的不同组合得到的预期排序结果
:widths: 25 25 50
:header-rows: 1
* - 参数 `sampler`
- 参数 `shuffle`
- 预期数据顺序
* - None
- None
- 随机排列
* - None
- True
- 随机排列
* - None
- False
- 顺序排列
* - `sampler` 实例
- None
- 由 `sampler` 行为定义的顺序
* - `sampler` 实例
- True
- 不允许
* - `sampler` 实例
- False
- 不允许
**关于DIV2K数据集**
DIV2K数据集由1000张2K分辨率图像组成其中800张用于训练100张用于验证100张用于测试。
作为NTIRE比赛的数据集NTIRE 2017 和 NTIRE 2018 仅包括DIV2K的训练数据集和验证数据集。
您可以解压缩原始DIV2K数据集文件到如下目录结构并通过MindSpore的API进行读取。
.. code-block::
.
└── DIV2K
├── DIV2K_train_HR
| ├── 0001.png
| ├── 0002.png
| ├── ...
├── DIV2K_train_LR_bicubic
| ├── X2
| | ├── 0001x2.png
| | ├── 0002x2.png
| | ├── ...
| ├── X3
| | ├── 0001x3.png
| | ├── 0002x3.png
| | ├── ...
| └── X4
| ├── 0001x4.png
| ├── 0002x4.png
| ├── ...
├── DIV2K_train_LR_unknown
| ├── X2
| | ├── 0001x2.png
| | ├── 0002x2.png
| | ├── ...
| ├── X3
| | ├── 0001x3.png
| | ├── 0002x3.png
| | ├── ...
| └── X4
| ├── 0001x4.png
| ├── 0002x4.png
| ├── ...
├── DIV2K_train_LR_mild
| ├── 0001x4m.png
| ├── 0002x4m.png
| ├── ...
├── DIV2K_train_LR_difficult
| ├── 0001x4d.png
| ├── 0002x4d.png
| ├── ...
├── DIV2K_train_LR_wild
| ├── 0001x4w.png
| ├── 0002x4w.png
| ├── ...
└── DIV2K_train_LR_x8
├── 0001x8.png
├── 0002x8.png
├── ...
**引用:**
.. code-block::
@InProceedings{Agustsson_2017_CVPR_Workshops,
author = {Agustsson, Eirikur and Timofte, Radu},
title = {NTIRE 2017 Challenge on Single Image Super-Resolution: Dataset and Study},
booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
url = "http://www.vision.ee.ethz.ch/~timofter/publications/Agustsson-CVPRW-2017.pdf",
month = {July},
year = {2017}
}
.. include:: mindspore.dataset.Dataset.add_sampler.rst
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.use_sampler.rst
.. include:: mindspore.dataset.Dataset.zip.rst

View File

@ -12,8 +12,8 @@
**异常:**
- **TypeError** - `apply_func` 的类型不是函数。
- **TypeError** - `apply_func` 未返回Dataset对象。
- **TypeError** - `apply_func` 的类型不是函数。
- **TypeError** - `apply_func` 未返回Dataset对象。
.. py:method:: batch(batch_size, drop_remainder=False, num_parallel_workers=None, per_batch_map=None, input_columns=None, output_columns=None, column_order=None, pad_info=None, python_multiprocessing=False, max_rowsize=16)

View File

@ -233,7 +233,7 @@ mindspore.dataset.GraphData
**异常:**
**TypeError** 参数 `edge_list` 不为列表或ndarray。
**TypeError** 参数 `edge_list` 不为列表或ndarray。
.. py:method:: get_node_feature(node_list, feature_types)

View File

@ -15,12 +15,12 @@ mindspore.dataset.PKSampler
**异常:**
- **TypeError** `shuffle` 不是bool值。
- **TypeError** `class_column` 不是str值。
- **TypeError** `num_samples` 不是整数值。
- **NotImplementedError** `num_class` 不为None。
- **RuntimeError** `num_val` 不是正值。
- **ValueError** `num_samples` 为负值。
- **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

View File

@ -12,9 +12,9 @@ mindspore.dataset.RandomSampler
**异常:**
- **TypeError** `replacement` 不是bool值。
- **TypeError** `num_samples` 不是整数值。
- **ValueError** `num_samples` 为负值。
- **TypeError** `replacement` 不是bool值。
- **TypeError** `num_samples` 不是整数值。
- **ValueError** `num_samples` 为负值。
.. include:: mindspore.dataset.BuiltinSampler.rst

View File

@ -29,7 +29,7 @@ mindspore.dataset.Schema
**异常:**
**ValueError** 列类型未知。
**ValueError** 列类型未知。
.. py:method:: from_json(json_obj)
@ -41,9 +41,9 @@ mindspore.dataset.Schema
**异常:**
- **RuntimeError** 对象中存在未知的项。
- **RuntimeError** 对象中缺少数据集类型。
- **RuntimeError** 对象中缺少列。
- **RuntimeError** 对象中存在未知的项。
- **RuntimeError** 对象中缺少数据集类型。
- **RuntimeError** 对象中缺少列。
.. py:method:: parse_columns(columns)

View File

@ -12,10 +12,10 @@ mindspore.dataset.SequentialSampler
**异常:**
- **TypeError** `start_index` 不是整数值。
- **TypeError** `num_samples` 不是整数值。
- **RuntimeError** `start_index` 为负值。
- **ValueError** `num_samples` 为负值。
- **TypeError** `start_index` 不是整数值。
- **TypeError** `num_samples` 不是整数值。
- **RuntimeError** `start_index` 为负值。
- **ValueError** `num_samples` 为负值。
.. include:: mindspore.dataset.BuiltinSampler.rst

View File

@ -12,8 +12,8 @@ mindspore.dataset.SubsetRandomSampler
**异常:**
- **TypeError** `indices` 的类型不是整数。
- **TypeError** `num_samples` 不是整数值。
- **ValueError** `num_samples` 为负值。
- **TypeError** `indices` 的类型不是整数。
- **TypeError** `num_samples` 不是整数值。
- **ValueError** `num_samples` 为负值。
.. include:: mindspore.dataset.BuiltinSampler.rst

View File

@ -12,8 +12,8 @@ mindspore.dataset.SubsetSampler
**异常:**
- **TypeError** `indices` 的类型不是整数。
- **TypeError** `num_samples` 不是整数值。
- **ValueError** `num_samples` 为负值。
- **TypeError** `indices` 的类型不是整数。
- **TypeError** `num_samples` 不是整数值。
- **ValueError** `num_samples` 为负值。
.. include:: mindspore.dataset.BuiltinSampler.rst

View File

@ -13,11 +13,11 @@ mindspore.dataset.WeightedRandomSampler
**异常:**
- **TypeError** `weights` 元素的类型不是数字。
- **TypeError** `num_samples` 不是整数值。
- **TypeError** `replacement` 不是布尔值。
- **RuntimeError** `weights` 为空或全为零。
- **ValueError** `num_samples` 为负值。
- **TypeError** `weights` 元素的类型不是数字。
- **TypeError** `num_samples` 不是整数值。
- **TypeError** `replacement` 不是布尔值。
- **RuntimeError** `weights` 为空或全为零。
- **ValueError** `num_samples` 为负值。
.. include:: mindspore.dataset.BuiltinSampler.rst

View File

@ -0,0 +1,3 @@
此模块用于文本数据增强,包括 `transforms``utils` 两个子模块。
`transforms` 是一个高性能文本数据增强模块,支持常见的文本数据增强处理。
`utils` 提供了一些文本处理的工具方法。

View File

@ -0,0 +1,8 @@
mindspore.dataset.text.transforms.CaseFold
==========================================
.. py:class:: mindspore.dataset.text.transforms.CaseFold()
对UTF-8字符串进行大小写转换相比 :func:`str.lower` 支持更多字符。
.. note:: Windows 平台尚不支持 CaseFold。

View File

@ -0,0 +1,56 @@
mindspore.dataset.text.transforms.JiebaTokenizer
================================================
.. py:class:: mindspore.dataset.text.transforms.JiebaTokenizer(hmm_path, mp_path, mode=JiebaMode.MIX, with_offsets=False)
使用Jieba分词器对中文字符串进行分词。
.. note:: 必须保证 HMMSEgment 算法和 MPSegment 算法所使用的字典文件的完整性。
**参数:**
- **hmm_path** (str) - HMMSegment 算法使用的字典文件路径字典可在cppjieba官网获取
详见 `cppjieba_github <https://github.com/yanyiwu/cppjieba/tree/master/dict>`_
- **mp_path** (str) - MPSegment 算法使用的字典文件路径字典可在cppjieba官网获取
详见 `cppjieba_github <https://github.com/yanyiwu/cppjieba/tree/master/dict>`_
- **mode** (JiebaMode, 可选) - Jieba分词使用的模式可以取值为 JiebaMode.MP、JiebaMode.HMM 或 JiebaMode.MIX。默认值JiebaMode.MIX。
- **JiebaMode.MP**:使用最大概率法算法进行分词。
- **JiebaMode.HMM**:使用隐马尔可夫模型算法进行分词。
- **JiebaMode.MIX**:使用 MPSegment 和 HMMSegment 算法混合进行分词。
- **with_offsets** (bool, 可选) - 是否输出标记(token)的偏移量默认值False。
**异常:**
- **ValueError** - 没有提供参数 `hmm_path` 或为None。
- **ValueError** - 没有提供参数 `mp_path` 或为None。
- **TypeError** - 参数 `hmm_path``mp_path` 类型不为string。
- **TypeError** - 参数 `with_offsets` 类型不为bool。
.. py:method:: add_word(self, word, freq=None)
将用户定义的词添加到 JiebaTokenizer 的字典中。
**参数:**
- **word** (str) - 要添加到 JiebaTokenizer 词典中的单词,注意通过此接口添加的单词不会被写入本地的模型文件中。
- **freq** (int可选) - 要添加的单词的频率。频率越高单词被分词的机会越大。默认值None使用默认频率。
.. py:method:: add_dict(self, user_dict)
将用户定义的词添加到 JiebaTokenizer 的字典中。
**参数:**
- **user_dict** (Union[str, dict]) - 有两种输入方式。可以通过指定jieba字典格式的文件路径加载。
要求的jieba字典格式为[wordfreq],如:
.. code-block::
word1 freq1
word2 None
word3 freq3
也可以通过Python dict加载要求的 Python 字典格式为:{word1:freq1, word2:freq2,...}。
只有用户提供的文件中有效的词对才会被添加到字典中,无的效输入行将被忽略,且不返回错误或警告状态。

View File

@ -0,0 +1,20 @@
mindspore.dataset.text.transforms.Lookup
========================================
.. py:class:: mindspore.dataset.text.transforms.Lookup(vocab, unknown_token=None, data_type=mstype.int32)
根据词表,将分词标记(token)映射到其索引值(id)。
**参数:**
- **vocab** (Vocab) - 词表对象,用于存储分词和索引的映射。
- **unknown_token** (str, 可选) - 备用词汇,用于在单词不在词汇表中的情况。
即如果单词不在词汇表中,则查找结果将替换为 `unknown_token` 的值。
如果如果单词不在词汇表中,且未指定 `unknown_token` 将抛出运行时错误。默认值None不指定该参数。
- **data_type** (mindspore.dtype, 可选): Lookup输出的数据类型默认值mindspore.int32。
**异常:**
- **TypeError** - 参数 `vocab` 类型不为 text.Vocab。
- **TypeError** - 参数 `unknown_token` 类型不为string。
- **TypeError** - 参数 `data_type` 类型不为 mindspore.dtype。

View File

@ -0,0 +1,27 @@
mindspore.dataset.text.transforms.Ngram
=======================================
.. py:class:: mindspore.dataset.text.transforms.Ngram(n, left_pad=("", 0), right_pad=("", 0), separator=" ")
从1-D的字符串生成N-gram。
关于N-gram是什么以及它是如何工作的请参阅 `N-gram <https://en.wikipedia.org/wiki/N-gram#Examples>`_
**参数:**
- **n** (list[int]) - n-gram 中的 n它是一个正整数列表。例如 n=[4, 3]结果将是Tensor包含一个4-gram和一个3-gram的字符串。
如果输入的字符不足以构造一个n-gram则返回一个空字符串。例如在["mindspore", "best"] 应用 3-gram 将导致生成一个空字符串。
- **left_pad** (tuple, 可选) - 指定序列的左侧填充传入tuple的形式为 ("pad_token",pad_width)。
pad_width 的上限值为 `n` -1。例如指定 left_pad=("_", 2) 将用 "__" 填充序列的左侧。默认值:("", 0)。
- **right_pad** (tuple, 可选) - 指定序列的右侧填充传入tuple的形式为 ("pad_token",pad_width)。
pad_width 的上限值为 `n` -1。例如指定 left_pad=("_", 2) 将用 "__" 填充序列的右侧。默认值:("", 0)。
- **separator** (str, 可选) - 指定用于将字符串连接在一起的分隔符。
例如,如果对 ["mindspore", "amazing"] 应用 2-gram 并指定分隔符为"-",结果将是 ["mindspore-amazing"]。默认值:" ",使用空格作为分隔符。
**异常:**
- **TypeError** - 参数 `n` 包含的值类型不为int。
- **ValueError** - 参数 `n` 包含的值不为正数。
- **ValueError** - 参数 `left_pad` 不是一个长度2的tuple。
- **ValueError** - 参数 `right_pad` 不是一个长度2的tuple。
- **TypeError** - 参数 `separator` 的类型不是bool。

View File

@ -0,0 +1,26 @@
mindspore.dataset.text.transforms.NormalizeUTF8
===============================================
.. py:class:: mindspore.dataset.text.transforms.NormalizeUTF8(normalize_form=NormalizeForm.NFKC)
对UTF-8编码的字符串进行规范化处理。
.. note:: Windows 平台尚不支持 NormalizeUTF8。
**参数:**
- **normalize_form** (NormalizeForm, 可选) - 指定不同的规范化形式,可以取值为
NormalizeForm.NONE, NormalizeForm.NFC, NormalizeForm.NFKC、NormalizeForm.NFD、NormalizeForm.NFKD 此四种unicode中的
任何一种形式默认值NormalizeForm.NFKC。
- NormalizeForm.NONE对输入字符串不做任何处理。
- NormalizeForm.NFC对输入字符串进行C形式规范化。
- NormalizeForm.NFKC对输入字符串进行KC形式规范化。
- NormalizeForm.NFD对输入字符串进行D形式规范化。
- NormalizeForm.NFKD对输入字符串进行KD形式规范化。
有关规范化详细信息,请参阅 http://unicode.org/reports/tr15/。
**异常:**
- **TypeError** - 参数 `normalize_form` 的类型不是NormalizeForm。

View File

@ -0,0 +1,14 @@
mindspore.dataset.text.transforms.PythonTokenizer
=================================================
.. py:class:: mindspore.dataset.text.transforms.PythonTokenizer(tokenizer)
使用用户自定义的分词器对输入字符串进行分词。
**参数:**
- **tokenizer** (Callable) - Python可调用对象要求接收一个string参数作为输入并返回一个包含多个string的列表作为返回值。
**异常:**
- **TypeError** - 参数 `tokenizer` 不是一个可调用的Python对象。

View File

@ -0,0 +1,22 @@
mindspore.dataset.text.transforms.RegexReplace
==============================================
.. py:class:: mindspore.dataset.text.transforms.RegexReplace(pattern, replace, replace_all=True)
根据正则表达式对UTF-8编码格式的字符串内容进行正则替换。
有关支持的正则表达式的模式,请参阅 https://unicode-org.github.io/icu/userguide/strings/regexp.html。
.. note:: Windows 平台尚不支持 RegexReplace。
**参数:**
- **pattern** (str) - 正则表达式的模式。
- **replace** (str) - 替换匹配元素的字符串。
- **replace_all** (bool, 可选): 如果为False只替换第一个匹配的元素 如果为True则替换所有匹配的元素。默认值True。
**异常:**
- **TypeError** - 参数 `pattern` 的类型不是string。
- **TypeError** - 参数 `replace` 的类型不是string。
- **TypeError** - 参数 `separator` 的类型不是bool。

View File

@ -0,0 +1,23 @@
mindspore.dataset.text.transforms.RegexTokenizer
================================================
.. py:class:: mindspore.dataset.text.transforms.RegexTokenizer(delim_pattern, keep_delim_pattern='', with_offsets=False)
根据正则表达式对字符串进行分词。
有关支持的正则表达式的模式,请参阅 https://unicode-org.github.io/icu/userguide/strings/regexp.html。
.. note:: Windows 平台尚不支持 RegexTokenizer。
**参数:**
- **delim_pattern** (str) - 以正则表达式表示的分隔符,字符串将被正则匹配的分隔符分割。
- **keep_delim_pattern** (str, 可选) - 如果被 `delim_pattern` 匹配的字符串也能被 `keep_delim_pattern` 匹配,就可以此分隔符作为标记(token)保存。
默认值:'',即分隔符不会作为输出标记保留。
- **with_offsets** (bool, 可选) - 是否输出标记(token)的偏移量默认值False不输出。
**异常:**
- **TypeError** - 参数 `delim_pattern` 的类型不是string。
- **TypeError** - 参数 `keep_delim_pattern` 的类型不是string。
- **TypeError** - 参数 `with_offsets` 的类型不是bool。

View File

@ -0,0 +1,20 @@
mindspore.dataset.text.transforms.SentencePieceTokenizer
========================================================
.. py:class:: mindspore.dataset.text.transforms.SentencePieceTokenizer(mode, out_type)
使用SentencePiece分词器对字符串进行分词。
**参数:**
- **mode** (Union[str, SentencePieceVocab]) - 如果输入是字符串则代表SentencePiece模型文件的路径
如果输入是SentencePieceVocab类型则代表一个SentencePieceVocab 对象。
- **out_type** (SPieceTokenizerOutType) - 分词器输出的类型,可以取值为 SPieceTokenizerOutType.STRING 或 SPieceTokenizerOutType.INT。
- SPieceTokenizerOutType.STRING表示 SentencePice分词器 的输出类型是字符串。
- SPieceTokenizerOutType.INT表示 SentencePice分词器 的输出类型是整型。
**异常:**
- **TypeError** - 参数 `mode` 的类型不是string或SentencePieceVocab。
- **TypeError** - 参数 `out_type` 的类型不是SPieceTokenizerOutType。

View File

@ -0,0 +1,17 @@
mindspore.dataset.text.transforms.SlidingWindow
===============================================
.. py:class:: mindspore.dataset.text.transforms.SlidingWindow(width, axis=0)
在输入数据的某个维度上进行滑窗切分处理。
**参数:**
- **width** (str) - 窗口的宽度,它必须是整数并且大于零。
- **axis** (int, 可选) - 计算滑动窗口的轴默认值0。
**异常:**
- **TypeError** - 参数 `width` 的类型不是int。
- **ValueError** - 参数 `width` 的值不是正数。
- **TypeError** - 参数 `axis` 的类型不是int。

View File

@ -0,0 +1,19 @@
mindspore.dataset.text.transforms.ToNumber
==========================================
.. py:class:: mindspore.dataset.text.transforms.ToNumber(data_type)
将字符串的每个元素转换为数字。
字符串根据以下链接中指定的规则进行转换,除了任何表示负数的字符串不能转换为无符号整数类型外,规则链接如下:
https://en.cppreference.com/w/cpp/string/basic_string/stof
https://en.cppreference.com/w/cpp/string/basic_string/stoul。
**参数:**
- **data_type** (mindspore.dtype) - 要转换为的数值类型,需要是在 mindspore.dtype 定义的数值类型。
**异常:**
- **TypeError** - 参数 `data_type` 的类型不是mindspore.dtype。
- **RuntimeError** - 字符串类型转换失败,或类型转换时出现溢出。

View File

@ -0,0 +1,16 @@
mindspore.dataset.text.transforms.TruncateSequencePair
======================================================
.. py:class:: mindspore.dataset.text.transforms.TruncateSequencePair(max_length)
截断一对 1-D 字符串的内容,使其总长度小于给定长度。
TruncateSequencePair接收两个Tensor作为输入并返回两个Tensor作为输出。
**参数:**
- **max_length** (int) - 最大截断长度。
**异常:**
- **TypeError** - 参数 `max_length` 的类型不是int。

View File

@ -0,0 +1,14 @@
mindspore.dataset.text.transforms.UnicodeCharTokenizer
======================================================
.. py:class:: mindspore.dataset.text.transforms.UnicodeCharTokenizer(with_offsets=False)
使用Unicode分词器将字符串分词为Unicode字符。
**参数:**
- **with_offsets** (bool, 可选) - 是否输出标记(token)的偏移量默认值False。
**异常:**
- **TypeError** - 参数 `with_offsets` 的类型不为bool。

View File

@ -0,0 +1,18 @@
mindspore.dataset.text.transforms.UnicodeScriptTokenizer
========================================================
.. py:class:: mindspore.dataset.text.transforms.UnicodeScriptTokenizer(keep_whitespace=False, with_offsets=False)
使用UnicodeScript分词器对字符串进行分词。
.. note:: Windows 平台尚不支持 UnicodeScriptTokenizer。
**参数:**
- **keep_whitespace** (bool, 可选) - 是否输出空白标记(token)默认值False。
- **with_offsets** (bool, 可选) - 是否输出标记(token)的偏移量默认值False。
**异常:**
- **TypeError** - 参数 `keep_whitespace` 的类型不为bool。
- **TypeError** - 参数 `with_offsets` 的类型不为bool。

View File

@ -0,0 +1,16 @@
mindspore.dataset.text.transforms.WhitespaceTokenizer
=====================================================
.. py:class:: mindspore.dataset.text.transforms.WhitespaceTokenizer(with_offsets=False)
基于ICU4C定义的空白字符' ', '\\\\t', '\\\\r', '\\\\n')对输入字符串进行分词。
.. note:: Windows 平台尚不支持 WhitespaceTokenizer。
**参数:**
- **with_offsets** (bool, 可选) - 是否输出标记(token)的偏移量默认值False。
**异常:**
- **TypeError** - 参数 `with_offsets` 的类型不为bool。

View File

@ -0,0 +1,24 @@
mindspore.dataset.text.transforms.WordpieceTokenizer
====================================================
.. py:class:: mindspore.dataset.text.transforms.WordpieceTokenizer(vocab, suffix_indicator='##', max_bytes_per_token=100,unknown_token='[UNK]', with_offsets=False)
对输入的1-D字符串分词为子词(subword)标记。
**参数:**
- **vocab** (Vocab) - 词汇表对象。
- **suffix_indicator** (str, 可选) - 用来表示子词是某个词的一部分,默认值:'##'。
- **max_bytes_per_token** (int可选) - 指定最长标记(token)的长度,超过此长度的标记将不会被进一步拆分。
- **unknown_token** (str可选) - 当词表中无法找到某个标记(token)时,将替换为此参数的值。
如果此参数为空字符串,则直接返回该标记。默认值:'[UNK]'。
- **with_offsets** (bool, 可选) - 是否输出标记(token)的偏移量默认值False。
**异常:**
- **TypeError** - 参数 `vocab` 的类型不为text.Vocab。
- **TypeError** - 参数 `suffix_indicator` 的类型不为string。
- **TypeError** - 参数 `max_bytes_per_token` 的类型不为int。
- **TypeError** - 参数 `unknown_token` 的类型不为string。
- **TypeError** - 参数 `with_offsets` 的类型不为bool。
- **TypeError** - 参数 `max_bytes_per_token` 的值为非负数。

View File

@ -0,0 +1,17 @@
mindspore.dataset.transforms.c_transforms.Compose
=================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Compose(transforms)
将多个数据增强算子组合使用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为 list。
- **ValueError** - 参数 `transforms` 的长度为空。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象
或类型不为 :class:`mindspore.dataset.transforms.c_transforms.TensorOperation`

View File

@ -0,0 +1,18 @@
mindspore.dataset.transforms.c_transforms.Concatenate
=====================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Concatenate(axis=0, prepend=None, append=None)
在Tensor的某一个轴上进行元素拼接。
**参数:**
- **axis** (int, 可选) - 指定一个轴用于拼接Tensor默认值0。
- **prepend** (numpy.array, 可选) - 指定拼接在最前面的Tensor默认值None不指定。
- **append** (numpy.array, 可选) - 指定拼接在最后面的Tensor默认值None不指定。
**异常:**
- **TypeError** - 参数 `axis` 的类型不为 int。
- **TypeError** - 参数 `prepend` 的类型不为 numpy.array。
- **TypeError** - 参数 `append` 的类型不为 numpy.array。

View File

@ -0,0 +1,10 @@
mindspore.dataset.transforms.c_transforms.Duplicate
===================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Duplicate()
将输入的数据列复制得到新的数据列每次仅可以输入1个数据列进行复制。
**异常:**
- **RuntimeError** - 输入数据列数量大于1。

View File

@ -0,0 +1,14 @@
mindspore.dataset.transforms.c_transforms.Fill
==============================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Fill(fill_value)
将Tensor的所有元素都赋值为指定的值输出Tensor将具有与输入Tensor具有相同的shape和数据类型。
**参数:**
- **fill_value** (Union[str, bytes, int, float, bool]) - 用于填充Tensor的值。
**异常:**
- **TypeError** - 参数 `fill_value` 类型不为 string、float、bool、int 或 bytes。

View File

@ -0,0 +1,19 @@
mindspore.dataset.transforms.c_transforms.Mask
==============================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Mask(operator, constant, dtype=mstype.bool_)
用给条件判断输入Tensor的内容并返回一个掩码Tensor。Tensor中任何符合条件的元素都将被标记为True否则为False。
**参数:**
- **operator** (Relational) - 关系操作符,可以取值为 Relational.EQ、Relational.NE、Relational.LT、
Relational.GT、Relational.LE、Relational.GE。以Relational.EQ为例将找出Tensor中与 `constant` 相等的元素。
- **constant** (Union[str, int, float, bool]) - 要进行比较的基准值。
- **dtype** (mindspore.dtype, 可选) - 生成的掩码Tensor的数据类型默认值mstype.bool。
**异常:**
- **TypeError** - 参数 `operator` 类型不为 Relational。
- **TypeError** - 参数 `constant` 类型不为 string, int, float 或 bool。
- **TypeError** - 参数 `dtype` 类型不为 mindspore.dtype。

View File

@ -0,0 +1,16 @@
mindspore.dataset.transforms.c_transforms.OneHot
================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.OneHot(num_classes)
将Tensor进行OneHot编码。
**参数:**
- **num_classes** (int) - 数据集的类别数它应该大于数据集中最大的label编号。
**异常:**
- **TypeError** - 参数 `num_classes` 类型不为 int。
- **RuntimeError** - 输入Tensor的类型不为 int。
- **RuntimeError** - 参数Tensor的shape不是1-D。

View File

@ -0,0 +1,21 @@
mindspore.dataset.transforms.c_transforms.PadEnd
================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.PadEnd(pad_shape, pad_value=None)
对输入Tensor进行填充要求填充值与Tensor的shape一致。
**参数:**
- **pad_shape** (list(int)) - 指定填充的shape。维度设置为'None'时将不会被填充,设置为较小的维数时该维度的元素将被截断。
- **pad_value** (Union[str, bytes, int, float, bool], 可选) - 用于填充的值。默认值None未指定填充值。
**异常:**
- **TypeError** - 参数 `pad_shape` 的类型不为 list。
- **TypeError** - 参数 `pad_value` 的类型不为 string, float, bool, int 或 bytes。
- **TypeError** - 参数 `pad_value` 的元素类型不为 int。
- **ValueError** - 参数 `pad_value` 的元素类型不为正数。

View File

@ -0,0 +1,20 @@
mindspore.dataset.transforms.c_transforms.RandomApply
=====================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.RandomApply(transforms, prob=0.5)
在一组数据增强中按概率应用其中的增强处理。
**参数:**
- **transforms** (transforms) - 一个数据增强的列表。
- **prob** (float, 可选) - 随机应用某个数据增强的概率默认值0.5。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为 list。
- **ValueError** - 参数 `transforms` 的长度为空。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象
或类型不为 :class:`mindspore.dataset.transforms.c_transforms.TensorOperation`
- **TypeError** - 参数 `prob` 的类型不为bool。
- **ValueError** - 参数 `prob` 的取值范围不为[0.0, 1.0]。

View File

@ -0,0 +1,17 @@
mindspore.dataset.transforms.c_transforms.RandomChoice
======================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.RandomChoice(transforms)
在一组数据增强中随机选择部分增强处理进行应用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为 list。
- **ValueError** - 参数 `transforms` 的长度为空。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象
或类型不为 :class:`mindspore.dataset.transforms.c_transforms.TensorOperation`

View File

@ -0,0 +1,13 @@
mindspore.dataset.transforms.c_transforms.Relational
====================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Relational()
关系操作符可以取值为Relational.EQ、Relational.NE、Relational.GT、Relational.GE、Relational.LT、Relational.LE。
- **Relational.EQ** - 相等关系。
- **Relational.NE** - 不相等关系。
- **Relational.GT** - 大于关系。
- **Relational.GE** - 大于等于关系。
- **Relational.LT** - 小于关系。
- **Relational.LE** - 小于等于关系。

View File

@ -0,0 +1,20 @@
mindspore.dataset.transforms.c_transforms.Slice
===============================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Slice(*slices)
对Tensor进行切片操作功能类似于NumPy的索引(目前只支持1D形状的Tensor)。
**参数:**
- **slices** ((Union[int, list[int], slice, None, Ellipsis]) - 指定切片的信息,可以为
- 1. :py:obj: 'int': 沿着第一个维度切片对索引进行切片,支持负索引。
- 2. :py:obj: 'list(int)': 沿着第一个维度切片所有索引进行切片,支持负号索引。
- 3. :py:obj: 'slice': 沿着第一个维度对slice对象生成的索引进行切片。
- 4. :py:obj: 'None': 切片整个维度类似于Python索引中的语法:py:obj: '[:]'。
- 5. :py:obj: 'Ellipsis': 切片整个维度,效果与'None '相同。
**异常:**
- **TypeError** - 参数 `slices` 类型不为 int, list[int], slice, None 或 Ellipsis。

View File

@ -0,0 +1,6 @@
mindspore.dataset.transforms.c_transforms.TensorOperation
=========================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.TensorOperation()
数据增强处理的基类其作为mindspore.dataset.transforms.c_transforms模块中数据增强的基类。

View File

@ -0,0 +1,14 @@
mindspore.dataset.transforms.c_transforms.TypeCast
==================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.TypeCast(data_type)
将输入的Tensor转换为指定的数据类型。
**参数:**
- **data_type** (mindspore.dtype) - 指定要转换的数据类型。
**异常:**
- **TypeError** - 参数 `data_type` 类型不为 MindSpore支持的数据类型如bool、int、float 或 string。

View File

@ -0,0 +1,13 @@
mindspore.dataset.transforms.c_transforms.Unique
================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Unique()
对输入张量进行唯一运算,每次只支持对一个数据列进行变换。
Unique将返回3个Tensor: 运算结果Tensor索引Tensor计数Tensor。
运算结果Tensor包含输入张量的所有唯一元素且和输入张量的顺序是一样的。
索引Tensor包含输入Tensor的每个元素在运算结果中的索引。
计数Tensor包含运算结果Tensor的每个元素的计数。
.. note:: 这个操作需要在batch操作之后调用.

View File

@ -0,0 +1,16 @@
mindspore.dataset.transforms.py_transforms.Compose
==================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.Compose(transforms)
将多个数据增强算子组合使用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为 list。
- **ValueError** - 参数 `transforms` 的长度为空。
- **TypeError** - 参数 `transforms` 的元素不是Python的callable对象。

View File

@ -0,0 +1,17 @@
mindspore.dataset.transforms.py_transforms.OneHotOp
===================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.OneHotOp(num_classes, smoothing_rate=0.0)
将Tensor进行OneHot编码可以进一步对标签进行平滑处理。
**参数:**
- **num_classes** (int) - 数据集的类别数它应该大于数据集中最大的label编号。
- **num_classes** (float可选) - 标签平滑的系数默认值0.0。
**异常:**
- **TypeError** - 参数 `num_classes` 类型不为 int。
- **TypeError** - 参数 `smoothing_rate` 类型不为 float。
- **ValueError** - 参数 `smoothing_rate` 取值范围不为[0.0, 1.0]。

View File

@ -0,0 +1,7 @@
mindspore.dataset.transforms.py_transforms.PyTensorOperation
============================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.PyTensorOperation()
Python 数据增强处理的基类其作为vision、transforms的py_transform模块中数据增强的基类
包括mindspore.dataset.vision.py_transforms、mindspore.dataset.transforms.py_transforms。

View File

@ -0,0 +1,20 @@
mindspore.dataset.transforms.py_transforms.RandomApply
======================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.RandomApply(transforms, prob=0.5)
在一组数据增强中按概率应用其中的增强处理。
**参数:**
- **transforms** (transforms) - 一个数据增强的列表。
- **prob** (float, 可选) - 随机应用某个数据增强的概率默认值0.5。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为 list。
- **ValueError** - 参数 `transforms` 的长度为空。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象
或类型不为 :class:`mindspore.dataset.transforms.py_transforms.PyTensorOperation`
- **TypeError** - 参数 `prob` 的类型不为bool。
- **ValueError** - 参数 `prob` 的取值范围不为[0.0, 1.0]。

View File

@ -0,0 +1,17 @@
mindspore.dataset.transforms.py_transforms.RandomChoice
=======================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.RandomChoice(transforms)
在一组数据增强中随机选择部分增强处理进行应用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为 list。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象
或类型不为 :class:`mindspore.dataset.transforms.py_transforms.PyTensorOperation`
- **ValueError** - 参数 `transforms` 的长度为空。

View File

@ -0,0 +1,17 @@
mindspore.dataset.transforms.py_transforms.RandomOrder
======================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.RandomOrder(transforms)
将数据增强列表中的处理随机打乱,然后应用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为 list。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象
或类型不为 :class:`mindspore.dataset.transforms.py_transforms.PyTensorOperation`
- **ValueError** - 参数 `transforms` 的长度为空。

View File

@ -0,0 +1,3 @@
此模块用于通用数据增强,包括 `c_transforms``py_transforms` 两个子模块。
`c_transforms` 是一个高性能数据增强模块基于C++实现。
`py_transforms` 提供了一种基于Python和NumPy的实现方式。

View File

@ -110,9 +110,9 @@ class Caltech101Dataset(GeneratorDataset):
A source dataset that reads and parses Caltech101 dataset.
The columns of the generated dataset depend on the value of `target_type`.
When `target_type` is `category`, the columns are :py:obj:`[image, category]`.
When `target_type` is `annotation`, the columns are :py:obj:`[image, annotation]`.
When `target_type` is `all`, the columns are :py:obj:`[image, category, annotation]`.
When `target_type` is 'category', the columns are :py:obj:`[image, category]`.
When `target_type` is 'annotation', the columns are :py:obj:`[image, annotation]`.
When `target_type` is 'all', the columns are :py:obj:`[image, category, annotation]`.
The tensor of column :py:obj:`image` is of the uint8 type.
The tensor of column :py:obj:`category` is of the uint32 type.
The tensor of column :py:obj:`annotation` is a 2-dimensional ndarray that stores the contour of the image
@ -141,8 +141,8 @@ class Caltech101Dataset(GeneratorDataset):
Raises:
RuntimeError: If dataset_dir does not contain data files.
RuntimeError: If target_type is not set correctly.
RuntimeError: If num_parallel_workers exceeds the max thread numbers.
ValueError: If target_type is not set correctly.
ValueError: If num_parallel_workers exceeds the max thread numbers.
RuntimeError: If sampler and shuffle are specified at the same time.
RuntimeError: If sampler and sharding are specified at the same time.
RuntimeError: If num_shards is specified but shard_id is None.
@ -302,7 +302,7 @@ class Caltech256Dataset(MappableDataset, VisionBaseDataset):
Raises:
RuntimeError: If dataset_dir does not contain data files.
RuntimeError: If num_parallel_workers exceeds the max thread numbers.
ValueError: If num_parallel_workers exceeds the max thread numbers.
RuntimeError: If sampler and shuffle are specified at the same time.
RuntimeError: If sampler and sharding are specified at the same time.
RuntimeError: If num_shards is specified but shard_id is None.
@ -855,7 +855,7 @@ class CityscapesDataset(MappableDataset, VisionBaseDataset):
Raises:
RuntimeError: If dataset_dir is invalid or does not contain data files.
RuntimeError: If num_parallel_workers exceeds the max thread numbers.
ValueError: If num_parallel_workers exceeds the max thread numbers.
RuntimeError: If sampler and shuffle are specified at the same time.
RuntimeError: If sampler and sharding are specified at the same time.
RuntimeError: If num_shards is specified but shard_id is None.
@ -1268,7 +1268,7 @@ class DIV2KDataset(MappableDataset, VisionBaseDataset):
Raises:
RuntimeError: If dataset_dir is invalid or does not contain data files.
RuntimeError: If num_parallel_workers exceeds the max thread numbers.
ValueError: If num_parallel_workers exceeds the max thread numbers.
RuntimeError: If sampler and shuffle are specified at the same time.
RuntimeError: If sampler and sharding are specified at the same time.
RuntimeError: If num_shards is specified but shard_id is None.
@ -1388,6 +1388,7 @@ class DIV2KDataset(MappableDataset, VisionBaseDataset):
0001x8.png
0002x8.png
...
Citation:
.. code-block::

View File

@ -104,6 +104,15 @@ class JiebaTokenizer(TextTensorOperation):
- JiebaMode.MIX, tokenize with a mix of MPSegment and HMMSegment algorithm.
with_offsets (bool, optional): Whether or not output offsets of tokens (default=False).
Raises:
ValueError: If path of HMMSegment dict is not provided.
ValueError: If path of MPSegment dict is not provided.
TypeError: If `hmm_path` or `mp_path` is not of type string.
TypeError: If `with_offsets` is not of type bool.
Supported Platforms:
``CPU``
Examples:
>>> from mindspore.dataset.text import JiebaMode
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
@ -265,6 +274,14 @@ class Lookup(TextTensorOperation):
data_type (mindspore.dtype, optional): The data type that lookup operation maps
string to(default=mindspore.int32).
Raises:
TypeError: If `vocab` is not of type text.Vocab.
TypeError: If `unknown_token` is not of type string.
TypeError: If `data_type` is not of type mindspore.dtype.
Supported Platforms:
``CPU``
Examples:
>>> # Load vocabulary from list
>>> vocab = text.Vocab.from_list(['', '', '', '', ''])
@ -304,6 +321,16 @@ class Ngram(TextTensorOperation):
["mindspore", "amazing"] with separator="-", the result would be ["mindspore-amazing"]
(default=" ", which will use whitespace as separator).
Raises:
TypeError: If values of `n` not positive is not of type int.
ValueError: If values of `n` not positive.
ValueError: If `left_pad` is not a tuple of length 2.
ValueError: If `right_pad` is not a tuple of length 2.
TypeError: If `separator` is not of type string.
Supported Platforms:
``CPU``
Examples:
>>> ngram_op = text.Ngram(3, separator="-")
>>> output = ngram_op(["WildRose Country", "Canada's Ocean Playground", "Land of Living Skies"])
@ -337,6 +364,13 @@ class SentencePieceTokenizer(TextTensorOperation):
- SPieceTokenizerOutType.STRING, means output type of SentencePice Tokenizer is string.
- SPieceTokenizerOutType.INT, means output type of SentencePice Tokenizer is int.
Raises:
TypeError: If `mode` is not of type string or SentencePieceVocab.
TypError: If `out_type` is not of type SPieceTokenizerOutType.
Supported Platforms:
``CPU``
Examples:
>>> from mindspore.dataset.text import SentencePieceModel, SPieceTokenizerOutType
>>> sentence_piece_vocab_file = "/path/to/sentence/piece/vocab/file"
@ -364,6 +398,14 @@ class SlidingWindow(TextTensorOperation):
width (int): The width of the window. It must be an integer and greater than zero.
axis (int, optional): The axis along which the sliding window is computed (default=0).
Raises:
TypeError: If `width` is not of type int.
ValueError: If value of `width` is not positive.
TypError: If `axis` is not of type int.
Supported Platforms:
``CPU``
Examples:
>>> dataset = ds.NumpySlicesDataset(data=[[1, 2, 3, 4, 5]], column_names="col1")
>>> # Data before
@ -403,8 +445,12 @@ class ToNumber(TextTensorOperation):
data_type (mindspore.dtype): Type to be cast to. Must be a numeric type in mindspore.dtype.
Raises:
TypeError: If `data_type` is not of type mindspore.dtype.
RuntimeError: If strings are invalid to cast, or are out of range after being cast.
Supported Platforms:
``CPU``
Examples:
>>> from mindspore import dtype as mstype
>>> data = [["1", "2", "3"]]
@ -461,6 +507,12 @@ class TruncateSequencePair(TextTensorOperation):
Args:
max_length (int): Maximum length required.
Raises:
TypeError: If `max_length` is not of type int.
Supported Platforms:
``CPU``
Examples:
>>> dataset = ds.NumpySlicesDataset(data={"col1": [[1, 2, 3]], "col2": [[4, 5]]})
>>> # Data before
@ -492,6 +544,12 @@ class UnicodeCharTokenizer(TextTensorOperation):
Args:
with_offsets (bool, optional): Whether or not output offsets of tokens (default=False).
Raises:
TypeError: If `with_offsets` is not of type bool.
Supported Platforms:
``CPU``
Examples:
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
>>> tokenizer_op = text.UnicodeCharTokenizer(with_offsets=False)
@ -524,6 +582,17 @@ class WordpieceTokenizer(TextTensorOperation):
return the token directly, else return 'unknown_token' (default='[UNK]').
with_offsets (bool, optional): Whether or not output offsets of tokens (default=False).
Raises:
TypeError: If `vocab` is not of type text.Vocab.
TypeError: If `suffix_indicator` is not of type string.
TypeError: If `max_bytes_per_token` is not of type int.
TypeError: If `unknown_token` is not of type string.
TypeError: If `with_offsets` is not of type bool.
ValueError: If value of `max_bytes_per_token` is negative.
Supported Platforms:
``CPU``
Examples:
>>> vocab_list = ["book", "cholera", "era", "favor", "##ite", "my", "is", "love", "dur", "##ing", "the"]
>>> vocab = text.Vocab.from_list(vocab_list)
@ -561,6 +630,12 @@ class PythonTokenizer:
Args:
tokenizer (Callable): Python function that takes a `str` and returns a list of `str` as tokens.
Raises:
TypeError: If `tokenizer` is not a callable Python function.
Supported Platforms:
``CPU``
Examples:
>>> def my_tokenizer(line):
... return line.split()
@ -749,6 +824,9 @@ if platform.system().lower() != 'windows':
Note:
CaseFold is not supported on Windows platform yet.
Supported Platforms:
``CPU``
Examples:
>>> case_op = text.CaseFold()
>>> text_file_dataset = text_file_dataset.map(operations=case_op)
@ -793,6 +871,12 @@ if platform.system().lower() != 'windows':
- NormalizeForm.NFD, normalize with Normalization Form D.
- NormalizeForm.NFKD, normalize with Normalization Form KD.
Raises:
TypeError: If `normalize_form` is not of type NormalizeForm.
Supported Platforms:
``CPU``
Examples:
>>> from mindspore.dataset.text import NormalizeForm
>>> normalize_op = text.NormalizeUTF8(normalize_form=NormalizeForm.NFC)
@ -825,6 +909,14 @@ if platform.system().lower() != 'windows':
replace_all (bool, optional): If False, only replace first matched element;
if True, replace all matched elements (default=True).
Raises:
TypeError: If `pattern` is not of type string.
TypeError: If `replace` is not of type string.
TypeError: If `replace_all` not of type bool.
Supported Platforms:
``CPU``
Examples:
>>> pattern = 'Canada'
>>> replace = 'China'
@ -859,6 +951,14 @@ if platform.system().lower() != 'windows':
which means that delimiters will not be kept as an output token (default='').
with_offsets (bool, optional): Whether or not output offsets of tokens(default=False).
Raises:
TypeError: If `delim_pattern` is not of type string.
TypeError: If `keep_delim_pattern` is not of type string.
TypeError: If `with_offsets` not of type bool.
Supported Platforms:
``CPU``
Examples:
>>> # If with_offsets=False, default output is one column {["text", dtype=str]}
>>> delim_pattern = r"[ |,]"
@ -896,6 +996,13 @@ if platform.system().lower() != 'windows':
keep_whitespace (bool, optional): Whether or not emit whitespace tokens (default=False).
with_offsets (bool, optional): Whether or not output offsets of tokens (default=False).
Raises:
TypeError: If `keep_whitespace` is not of type bool.
TypeError: If `with_offsets` is not of type bool.
Supported Platforms:
``CPU``
Examples:
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
>>> tokenizer_op = text.UnicodeScriptTokenizer(keep_whitespace=True, with_offsets=False)
@ -931,6 +1038,12 @@ if platform.system().lower() != 'windows':
Args:
with_offsets (bool, optional): Whether or not output offsets of tokens (default=False).
Raises:
TypeError: If `with_offsets` is not of type bool.
Supported Platforms:
``CPU``
Examples:
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
>>> tokenizer_op = text.WhitespaceTokenizer(with_offsets=False)

View File

@ -13,8 +13,8 @@
# limitations under the License.
"""
This module is to support common augmentations. C_transforms is a high performance
image augmentation module which is developed with C++ OpenCV. Py_transforms
provide more kinds of image augmentations which are developed with Python PIL.
augmentation module which is developed by C++. Py_transforms provides an optional
implementation which is developed by Python & NumPy.
Common imported modules in corresponding API examples are as follows:

View File

@ -63,7 +63,12 @@ class OneHot(TensorOperation):
It should be larger than the largest label number in the dataset.
Raises:
RuntimeError: feature size is bigger than num_classes.
TypeError: num_classes is not of type int.
RuntimeError: Input tensor is not of type int.
RuntimeError: Input tensor is not a 1-D tensor.
Supported Platforms:
``CPU``
Examples:
>>> # Assume that dataset has 10 classes, thus the label ranges from 0 to 9
@ -88,6 +93,12 @@ class Fill(TensorOperation):
fill_value (Union[str, bytes, int, float, bool]) : scalar value
to fill the tensor with.
Raises:
TypeError: If `fill_value` is not of type str, float, bool, int or bytes.
Supported Platforms:
``CPU``
Examples:
>>> import numpy as np
>>> # generate a 1D integer numpy array from 0 to 4
@ -116,6 +127,12 @@ class TypeCast(TensorOperation):
Args:
data_type (mindspore.dtype): mindspore.dtype to be cast to.
Raises:
TypeError: If `data_type` is not of type bool, int, float or string.
Supported Platforms:
``CPU``
Examples:
>>> import numpy as np
>>> from mindspore import dtype as mstype
@ -183,6 +200,12 @@ class Slice(TensorOperation):
4. :py:obj:`None`: Slice the whole dimension. Similar to :py:obj:`[:]` in Python indexing.
5. :py:obj:`Ellipsis`: Slice the whole dimension, same result with `None`.
Raises:
TypeError: If `slices` is not of type int, list[int], slice, None or Ellipsis.
Supported Platforms:
``CPU``
Examples:
>>> # Data before
>>> # | col |
@ -289,6 +312,15 @@ class PadEnd(TensorOperation):
pad_value (Union[str, bytes, int, float, bool], optional): Value used to pad. Default to 0 or empty
string in case of tensors of strings.
Raises:
TypeError: If `pad_shape` is not of type list.
TypeError: If `pad_value` is not of type str, float, bool, int or bytes.
TypeError: If elements of `pad_shape` is not of type int.
ValueError: If elements of `pad_shape` is not of positive.
Supported Platforms:
``CPU``
Examples:
>>> # Data before
>>> # | col |
@ -325,6 +357,14 @@ class Concatenate(TensorOperation):
(Default=None).
append (numpy.array, optional): NumPy array to be appended to the already concatenated tensors (Default=None).
Raises:
TypeError: If `axis` is of type int.
TypeError: If `prepend` not of type numpy.ndarray.
TypeError: If `append` not of type numpy.ndarray.
Supported Platforms:
``CPU``
Examples:
>>> import numpy as np
>>> # concatenate string
@ -350,6 +390,12 @@ class Duplicate(TensorOperation):
"""
Duplicate the input tensor to output, only support transform one column each time.
Raises:
RuntimeError: If given tensor has two columns.
Supported Platforms:
``CPU``
Examples:
>>> # Data before
>>> # | x |
@ -420,6 +466,15 @@ class Compose(TensorOperation):
Args:
transforms (list): List of transformations to be applied.
Raises:
TypeError: If `transforms` is not of type list.
ValueError: If `transforms` is empty.
TypeError: If elements of `transforms` are neither Python callable objects nor have
type :class:`mindspore.dataset.transforms.c_transforms.TensorOperation` .
Supported Platforms:
``CPU``
Examples:
>>> compose = c_transforms.Compose([c_vision.Decode(), c_vision.RandomCrop(512)])
>>> image_folder_dataset = image_folder_dataset.map(operations=compose)
@ -447,6 +502,17 @@ class RandomApply(TensorOperation):
transforms (list): List of transformations to be applied.
prob (float, optional): The probability to apply the transformation list (default=0.5).
Raises:
TypeError: If `transforms` is not of type list.
ValueError: If `transforms` is empty.
TypeError: If elements of `transforms` are neither Python callable objects nor have
type :class:`mindspore.dataset.transforms.c_transforms.TensorOperation` .
TypeError: If `prob` is not of type bool.
ValueError: If `prob` is not in range [0.0, 1.0].
Supported Platforms:
``CPU``
Examples:
>>> rand_apply = c_transforms.RandomApply([c_vision.RandomCrop(512)])
>>> image_folder_dataset = image_folder_dataset.map(operations=rand_apply)
@ -474,6 +540,15 @@ class RandomChoice(TensorOperation):
Args:
transforms (list): List of transformations to be chosen from to apply.
Raises:
TypeError: If `transforms` is not of type list.
ValueError: If `transforms` is empty.
TypeError: If elements of `transforms` are neither Python callable objects nor have
type :class:`mindspore.dataset.transforms.c_transforms.TensorOperation` .
Supported Platforms:
``CPU``
Examples:
>>> rand_choice = c_transforms.RandomChoice([c_vision.CenterCrop(50), c_vision.RandomCrop(512)])
>>> image_folder_dataset = image_folder_dataset.map(operations=rand_choice)

View File

@ -96,6 +96,14 @@ class OneHotOp(PyTensorOperation):
smoothing_rate (float, optional): Adjustable hyperparameter for label smoothing level.
(Default=0.0 means no smoothing is applied.)
Raises:
TypeError: `num_classes` is not of type int.
TypeError: `smoothing_rate` is not of type float.
ValueError: `prob` is not in range [0.0, 1.0]
Supported Platforms:
``CPU``
Examples:
>>> # Assume that dataset has 10 classes, thus the label ranges from 0 to 9
>>> transforms_list = [py_transforms.OneHotOp(num_classes=10, smoothing_rate=0.1)]
@ -136,6 +144,14 @@ class Compose(PyTensorOperation):
Args:
transforms (list): List of transformations to be applied.
Raises:
TypeError: If `transforms` is not of type list.
ValueError: If `transforms` is empty.
TypeError: If transformations in `transforms` are not Python callable objects.
Supported Platforms:
``CPU``
Examples:
>>> image_folder_dataset_dir = "/path/to/image_folder_dataset_directory"
>>> # create a dataset that reads all files in dataset_dir with 8 threads
@ -239,6 +255,17 @@ class RandomApply(PyTensorOperation):
transforms (list): List of transformations to apply.
prob (float, optional): The probability to apply the transformation list (default=0.5).
Raises:
TypeError: If `transforms` is not of type list.
ValueError: If `transforms` is empty.
TypeError: If elements of `transforms` are neither Python callable objects nor have
type :class:`mindspore.dataset.transforms.py_transforms.PyTensorOperation` .
TypeError: If `prob` is not of type bool.
ValueError: If `prob` is not in range [0.0, 1.0].
Supported Platforms:
``CPU``
Examples:
>>> from mindspore.dataset.transforms.py_transforms import Compose
>>> transforms_list = [py_vision.RandomHorizontalFlip(0.5),
@ -275,6 +302,15 @@ class RandomChoice(PyTensorOperation):
Args:
transforms (list): List of transformations to be chosen from to apply.
Raises:
TypeError: If `transforms` is not of type list.
TypeError: If elements of `transforms` are neither Python callable objects nor have
type :class:`mindspore.dataset.transforms.py_transforms.PyTensorOperation` .
ValueError: If `transforms` is empty.
Supported Platforms:
``CPU``
Examples:
>>> from mindspore.dataset.transforms.py_transforms import Compose
>>> transforms_list = [py_vision.RandomHorizontalFlip(0.5),
@ -310,6 +346,15 @@ class RandomOrder(PyTensorOperation):
Args:
transforms (list): List of the transformations to apply.
Raises:
TypeError: If `transforms` is not of type list.
TypeError: If elements of `transforms` are neither Python callable objects nor have
type :class:`mindspore.dataset.transforms.py_transforms.PyTensorOperation` .
ValueError: If `transforms` is empty.
Supported Platforms:
``CPU``
Examples:
>>> from mindspore.dataset.transforms.py_transforms import Compose
>>> transforms_list = [py_vision.RandomHorizontalFlip(0.5),