!44882 fix: doc review MD

Merge pull request !44882 from guozhijian/fix_doc_review
This commit is contained in:
i-robot 2022-11-02 02:34:52 +00:00 committed by Gitee
commit b412570b7b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
41 changed files with 269 additions and 129 deletions

View File

@ -3,14 +3,13 @@ mindspore.dataset.Dataset.zip
.. py:method:: mindspore.dataset.Dataset.zip(datasets)
将多个dataset对象按列进行合并压缩。
将多个dataset对象按列进行合并压缩多个dataset对象不能有相同的列名
参数:
- **datasets** (tuple[Dataset]) - 要合并的多个dataset对象。 `datasets` 参数的长度必须大于1。
- **datasets** (tuple[Dataset]) - 要合并的多个dataset对象。
返回:
ZipDataset合并后的dataset对象。
异常:
- **ValueError** - `datasets` 参数的长度为1。
- **TypeError** - `datasets` 参数不是tuple。
- **TypeError** - `datasets` 参数不是dataset对象/tuple(dataset)。

View File

@ -3,7 +3,7 @@ mindspore.dataset.WikiTextDataset
.. py:class:: mindspore.dataset.WikiTextDataset(dataset_dir, usage=None, num_samples=None, num_parallel_workers=None, shuffle=Shuffle.GLOBAL, num_shards=None, shard_id=None, cache=None)
读取和解析WikiText2和WikiText103数据集的源数据集
读取和解析WikiText2和WikiText103数据集。
生成的数据集有一列 `[text]` 数据类型为string。
@ -22,6 +22,14 @@ mindspore.dataset.WikiTextDataset
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数默认值None。指定此参数后 `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号默认值None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/tutorials/experts/zh-CN/master/dataset/cache.html>`_ 。默认值None不使用缓存。
异常:
- **RuntimeError** - `dataset_dir` 参数所指向的文件目录不存在或缺少数据集文件。
- **ValueError** - `num_samples` 参数值错误小于0
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数值错误小于0或者大于等于 `num_shards` )。
**关于WikiText数据集**

View File

@ -8,6 +8,8 @@ mindspore.dataset.audio.ComputeDeltas
.. math::
d_{t}=\frac{{\textstyle\sum_{n=1}^{N}}n(c_{t+n}-c_{t-n})}{2{\textstyle\sum_{n=1}^{N}}n^{2}}
其中, :math:`d_{t}` 是时间 :math:`t` 的增量, :math:`c_{t}` 是时间 :math:`t` 的频谱图系数, :math:`N`:math:`(\text{win_length}-1)//2`
参数:
- **win_length** (int, 可选) - 计算窗口长度长度必须不小于3默认值5。
- **pad_mode** (:class:`mindspore.dataset.audio.BorderType`, 可选) - 边界填充模式,可以是

View File

@ -7,6 +7,11 @@ mindspore.dataset.audio.MaskAlongAxis
参数:
- **mask_start** (int) - 掩码的起始位置,必须是非负的。
- **mask_width** (int) - 掩码的宽度,必须是非负的
- **mask_width** (int) - 掩码的宽度,必须是大于0
- **mask_value** (float) - 掩码值。
- **axis** (int) - 要应用掩码的轴1表示频率2表示时间
异常:
- **ValueError** - `mask_start` 参数值错误小于0
- **ValueError** - `mask_width` 参数值错误小于1
- **ValueError** - `axis` 参数类型错误或者值错误,不属于 [1, 2]。

View File

@ -10,3 +10,7 @@ mindspore.dataset.audio.MaskAlongAxisIID
- **mask_param** (int) - 要屏蔽的列数,将从[0, mask_param]统一采样,必须是非负数。
- **mask_value** (float) - 掩码值。
- **axis** (int) - 要应用掩码的轴1表示频率2表示时间
异常:
- **ValueError** - `mask_param` 参数值错误小于0
- **ValueError** - `axis` 参数类型错误或者值错误,不属于 [1, 2]。

View File

@ -3,7 +3,7 @@ mindspore.dataset.audio.SlidingWindowCmn
.. py:class:: mindspore.dataset.audio.SlidingWindowCmn(cmn_window=600, min_cmn_window=100, center=False, norm_vars=False)
应用滑动窗口倒谱平均值(和可选的方差)标准化每个对话语句
对每个话语应用滑动窗口倒谱均值(和可选方差)归一化
参数:
- **cmn_window** (int, 可选) - 用于运行平均CMN计算的帧中窗口默认值600。
@ -11,4 +11,4 @@ mindspore.dataset.audio.SlidingWindowCmn
仅在中心为False时适用在中心为True时忽略默认值100。
- **center** (bool, 可选) - 如果为True则使用以当前帧为中心的窗口。如果为False则窗口在左侧。默认值False。
- **norm_vars** (bool, 可选) - 如果为True则将方差规范化为1。默认值False。

View File

@ -3,7 +3,7 @@ mindspore.dataset.audio.WindowType
.. py:class:: mindspore.dataset.audio.WindowType
窗口函数类型
窗口函数类型
可选的枚举值包括WindowType.BARTTT、WindowType.BACKMAN、WindowType.HAMMING、WindowType.HANN、WindowType.KAISER。
@ -12,4 +12,4 @@ mindspore.dataset.audio.WindowType
- **WindowType.HAMMING** - 表示窗口函数的类型为Hamming。
- **WindowType.HANN** - 表示窗口函数的类型为Hann。
- **WindowType.KAISER** - 表示窗口函数的类型为Kaiser目前在macOS上不支持。

View File

@ -3,17 +3,22 @@
.. py:class:: mindspore.dataset.text.CharNGram
CharNGram对象用于将tokens映射到预训练的向量中。
CharNGram对象用于将 `tokens` 映射到预训练的向量中。
.. py:method:: from_file(file_path, max_vectors=None)
从文件构建CharNGram向量。
从文件构建 `CharNGram` 向量。
参数:
- **file_path** (str) - 包含CharNGram向量的文件路径。
- **file_path** (str) - 包含 `CharNGram` 向量的文件路径。
- **max_vectors** (int可选) - 用于限制加载的预训练向量的数量。
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
可以传递 `max_vectors` 限制加载数量。默认值None无限制。
返回:
CharNGram 根据文件构建的CharNGram向量。
异常:
- **RuntimeError** - `file_path` 参数所指向的文件非法或者包含的数据异常。
- **ValueError** - `max_vectors` 参数值错误。
- **TypeError** - `max_vectors` 参数不是整数类型。

View File

@ -3,17 +3,22 @@
.. py:class:: mindspore.dataset.text.FastText
用于将tokens映射到量的FastText对象。
用于将tokens映射到量的FastText对象。
.. py:method:: from_file(file_path, max_vectors=None)
从文件构建FastText向量。
参数:
- **file_path** (str) - 包含向量的文件路径。预训练向量集的文件后缀必须是 `*.vec`
- **file_path** (str) - 包含向量的文件路径。预训练向量集的文件后缀必须是 `*.vec`
- **max_vectors** (int可选) - 用于限制加载的预训练向量的数量。
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
可以传递 `max_vectors` 限制加载数量。默认值None无限制。
返回:
FastText 根据文件构建的FastText向量。
异常:
- **RuntimeError** - `file_path` 参数所指向的文件非法或者包含的数据异常。
- **ValueError** - `max_vectors` 参数值错误。
- **TypeError** - `max_vectors` 参数不是整数类型。

View File

@ -3,17 +3,22 @@
.. py:class:: mindspore.dataset.text.GloVe
用于将tokens映射到量的GloVe对象。
用于将tokens映射到量的GloVe对象。
.. py:method:: from_file(file_path, max_vectors=None)
从文件构建CharNGram向量。
参数:
- **file_path** (str) - 包含向量的文件路径。预训练向量集的格式必须是 `glove.6B.*.txt`
- **file_path** (str) - 包含向量的文件路径。预训练向量集的格式必须是 `glove.6B.*.txt`
- **max_vectors** (int可选) - 用于限制加载的预训练向量的数量。
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
可以传递 `max_vectors` 限制加载数量。默认值None无限制。
返回:
GloVe 根据文件构建的GloVe向量。
异常:
- **RuntimeError** - `file_path` 参数所指向的文件非法或者包含的数据异常。
- **ValueError** - `max_vectors` 参数值错误。
- **TypeError** - `max_vectors` 参数不是整数类型。

View File

@ -6,10 +6,10 @@ mindspore.dataset.text.ToVectors
根据输入向量表查找向量中的tokens。
参数:
- **vectors** (Vectors) - 量对象。
- **unk_init** (sequence, 可选) - 用于初始化量外OOV令牌的序列默认值None用零向量初始化。
- **vectors** (Vectors) - 量对象。
- **unk_init** (sequence, 可选) - 用于初始化量外OOV令牌的序列默认值None用零向量初始化。
- **lower_case_backup** (bool, 可选) - 是否查找小写的token。如果为False则将查找原始大小写中的每个token。
如果为True则将首先查找原始大小写中的每个token如果在属性soi的键中找不到则将查找小写中的token。默认值False。
如果为True则将首先查找原始大小写中的每个token如果在属性stoi(字符->索引映射)的键中找不到则将查找小写中的token。默认值False。
异常:
- **TypeError** - 如果 `unk_init` 不是序列。

View File

@ -3,17 +3,22 @@
.. py:class:: mindspore.dataset.text.Vectors
用于将tokens映射到量的Vectors对象。
用于将tokens映射到量的Vectors对象。
.. py:method:: from_file(file_path, max_vectors=None)
从文件构建Vectors向量。
参数:
- **file_path** (str) - 包含向量的文件路径。
- **file_path** (str) - 包含向量的文件路径。
- **max_vectors** (int可选) - 用于限制加载的预训练向量的数量。
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
可以传递 `max_vectors` 限制加载数量。默认值None无限制。
返回:
Vectors 根据文件构建的Vectors向量。
异常:
- **RuntimeError** - `file_path` 参数所指向的文件非法或者包含的数据异常。
- **ValueError** - `max_vectors` 参数值错误。
- **TypeError** - `max_vectors` 参数不是整数类型。

View File

@ -7,7 +7,7 @@ mindspore.dataset.transforms.RandomApply
参数:
- **transforms** (list) - 一个数据增强的列表。
- **prob** (float, 可选) - 随机应用某个数据增强的概率默认值0.5。
- **prob** (float, 可选) - 随机应用某个数据增强的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 参数 `transforms` 类型不为list。

View File

@ -12,7 +12,7 @@ mindspore.dataset.vision.AdjustGamma
参数:
- **gamma** (float) - 输出图像像素值与输入图像像素值呈指数相关。 `gamma` 大于1使阴影更暗`gamma` 小于1使黑暗区域更亮。
- **gain** (float, 可选) - 常数乘数默认值1。
- **gain** (float, 可选) - 常数乘数默认值1.0
异常:
- **TypeError** - 如果 `gain` 不是浮点类型。

View File

@ -22,14 +22,14 @@ mindspore.dataset.vision.AutoAugment
- **Inter.NEAREST**:表示插值方法是最近邻插值。
- **Inter.BILINEAR**:表示插值方法是双线性插值。
- **Inter.BICUBIC**:表示插值方法为双三次插值。
- **Inter.AREA**:表示插值方法为面积插值。
- **Inter.AREA**:表示插值方法为像素区域插值。
- **fill_value** (Union[int, tuple[int]], 可选) - 填充的像素值。
如果是3元素元组则分别用于填充R、G、B通道。
如果是整数,则用于所有 RGB 通道。 `fill_value` 值必须在 [0, 255] 范围内默认值0。
异常:
- **TypeError** - 如果 `policy` 不是AutoAugmentPolicy类型。
- **TypeError** - 如果 `interpolation` 不是Inter类型。
- **TypeError** - 如果 `policy` 不是 :class:`mindspore.dataset.vision.AutoAugmentPolicy` 类型。
- **TypeError** - 如果 `interpolation` 不是 :class:`mindsore.dataset.vision.Inter` 类型。
- **TypeError** - 如果 `fill_value` 不是整数或长度为3的元组。
- **RuntimeError** - 如果给定的张量形状不是<H, W, C>。

View File

@ -9,7 +9,7 @@ mindspore.dataset.vision.CutMixBatch
参数:
- **image_batch_format** (ImageBatchFormat) - 图像批处理输出格式。可以是 [ImageBatchFormat.NHWC、ImageBatchFormat.NCHW] 中的任何一个。
- **alpha** (float, 可选) - β分布的超参数必须大于0默认值1.0。
- **prob** (float, 可选) - 对每个图像应用剪切混合处理的概率,范围:[0.0, 1.0]默认值1.0。
- **prob** (float, 可选) - 对每个图像应用剪切混合处理的概率,取值范围:[0.0, 1.0]默认值1.0。
异常:
- **TypeError** - 如果 `image_batch_format` 不是 :class:`mindspore.dataset.vision.ImageBatchFormat` 的类型。

View File

@ -8,11 +8,11 @@ mindspore.dataset.vision.RandomAdjustSharpness
参数:
- **degree** (float) - 锐度调整度,必须是非负的。
0.0度表示模糊图像1.0度表示原始图像2.0度表示清晰度增加2倍。
- **prob** (float, 可选) - 图像被锐化的概率默认值0.5。
- **prob** (float, 可选) - 图像被锐化的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `degree` 的类型不为float。
- **TypeError** - 如果 `prob` 的类型不为bool
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围。
- **TypeError** - 如果 `prob` 的类型不为float
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围。
- **ValueError** - 如果 `degree` 为负数。
- **RuntimeError** -如果给定的张量形状不是<H, W>或<H, W, C>。

View File

@ -8,13 +8,13 @@ mindspore.dataset.vision.RandomAutoContrast
参数:
- **cutoff** (float, 可选) - 输入图像直方图中最亮和最暗像素的百分比。该值必须在 [0.0, 50.0) 范围内默认值0.0。
- **ignore** (Union[int, sequence], 可选) - 要忽略的背景像素值,忽略值必须在 [0, 255] 范围内默认值None。
- **prob** (float, 可选) - 图像被调整对比度的概率默认值0.5。
- **prob** (float, 可选) - 图像被调整对比度的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `cutoff` 不是float类型。
- **TypeError** - 如果 `ignore` 不是int或sequence类型。
- **TypeError** - 如果 `prob` 的类型不为bool
- **TypeError** - 如果 `prob` 的类型不为float
- **ValueError** - 如果 `cutoff` 不在[0, 50.0) 范围内。
- **ValueError** - 如果 `ignore` 不在[0, 255] 范围内。
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围。
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围。
- **RuntimeError** - 如果输入图像的shape不是 <H, W> 或 <H, W, C>。

View File

@ -6,9 +6,9 @@ mindspore.dataset.vision.RandomEqualize
以给定的概率随机对输入图像进行直方图均衡化。
参数:
- **prob** (float, 可选) - 图像被均衡化的概率默认值0.5。
- **prob** (float, 可选) - 图像被均衡化的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `prob` 的类型不为bool
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围。
- **TypeError** - 如果 `prob` 的类型不为float
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围。
- **RuntimeError** - 如果输入图像的shape不是 <H, W> 或 <H, W, C>。

View File

@ -8,7 +8,7 @@ mindspore.dataset.vision.RandomErasing
请参阅论文 `Random Erasing Data Augmentation <https://arxiv.org/pdf/1708.04896.pdf>`_
参数:
- **prob** (float可选) - 执行随机擦除的概率默认值0.5。
- **prob** (float可选) - 执行随机擦除的概率,取值范围:[0.0, 1.0]。默认值0.5。
- **scale** (Sequence[float, float],可选) - 擦除区域面积相对原图比例的随机选取范围,按照(min, max)顺序排列,默认值:(0.02, 0.33)。
- **ratio** (Sequence[float, float],可选) - 擦除区域宽高比的随机选取范围,按照(min, max)顺序排列,默认值:(0.3, 3.3)。
- **value** (Union[int, str, Sequence[int, int, int]]) - 擦除区域的像素填充值。若输入int将以该值填充RGB通道若输入Sequence[int, int, int]将分别用于填充R、G、B通道若输入字符串'random'将以从标准正态分布获得的随机值擦除各个像素。默认值0。
@ -22,7 +22,7 @@ mindspore.dataset.vision.RandomErasing
- **TypeError** - 当 `value` 的类型不为int、str或Sequence[int, int, int]。
- **TypeError** - 当 `inplace` 的类型不为bool。
- **TypeError** - 当 `max_attempts` 的类型不为int。
- **ValueError** - 当 `prob` 取值不在[0, 1]范围内。
- **ValueError** - 当 `prob` 取值不在[0.0, 1.0]范围内。
- **ValueError** - 当 `scale` 为负数。
- **ValueError** - 当 `ratio` 为负数。
- **ValueError** - 当 `value` 取值不在[0, 255]范围内。

View File

@ -6,8 +6,8 @@ mindspore.dataset.vision.RandomGrayscale
按照指定的概率将输入PIL图像转换为灰度图。
参数:
- **prob** (float可选) - 执行灰度转换的概率默认值0.1。
- **prob** (float可选) - 执行灰度转换的概率,取值范围:[0.0, 1.0]。默认值0.1。
异常:
- **TypeError** - 当 `prob` 的类型不为float。
- **ValueError** - 当 `prob` 取值不在[0, 1]范围内。
- **ValueError** - 当 `prob` 取值不在[0.0, 1.0]范围内。

View File

@ -6,9 +6,9 @@ mindspore.dataset.vision.RandomHorizontalFlip
对输入图像按给定的概率进行水平随机翻转。
参数:
- **prob** (float, 可选) - 图像被翻转的概率,必须在 [0, 1] 范围内,默认值0.5。
- **prob** (float, 可选) - 图像被翻转的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `prob` 不是float类型。
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围内。
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围内。
- **RuntimeError** - 如果输入图像的shape不是 <H, W> 或 <H, W, C>。

View File

@ -6,9 +6,9 @@ mindspore.dataset.vision.RandomHorizontalFlipWithBBox
对输入图像按给定的概率进行水平随机翻转并相应地调整边界框。
参数:
- **prob** (float, 可选) - 图像被翻转的概率,必须在 [0, 1] 范围内,默认值0.5。
- **prob** (float, 可选) - 图像被翻转的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `prob` 不是float类型。
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围内。
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围内。
- **RuntimeError** - 如果输入图像的shape不是 <H, W> 或 <H, W, C>。

View File

@ -6,9 +6,9 @@ mindspore.dataset.vision.RandomInvert
以给定的概率随机反转图像的颜色。
参数:
- **prob** (float, 可选) - 图像被反转颜色的概率默认值0.5。
- **prob** (float, 可选) - 图像被反转颜色的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `prob` 的类型不为bool
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围。
- **TypeError** - 如果 `prob` 的类型不为float
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围。
- **RuntimeError** - 如果输入图像的shape不是 <H, W, C>。

View File

@ -9,6 +9,6 @@ mindspore.dataset.vision.RandomLighting
- **alpha** (float, 可选) - 图像的强度必须是非负的。默认值0.05。
异常:
- **TypeError** - 如果 `alpha` 的类型不为bool
- **TypeError** - 如果 `alpha` 的类型不为float
- **ValueError** - 如果 `alpha` 为负数。
- **RuntimeError** - 如果输入图像的shape不是 <H, W, C>。

View File

@ -6,8 +6,8 @@ mindspore.dataset.vision.RandomPerspective
按照指定的概率对输入PIL图像进行透视变换。
参数:
- **distortion_scale** (float可选) - 失真程度,取值范围为[0, 1]默认值0.5。
- **prob** (float可选) - 执行透视变换的概率默认值0.5。
- **distortion_scale** (float可选) - 失真程度,取值范围为[0.0, 1.0]默认值0.5。
- **prob** (float可选) - 执行透视变换的概率,取值范围:[0.0, 1.0]。默认值0.5。
- **interpolation** (Inter可选) - 插值方式,取值可为 Inter.BILINEAR、Inter.NEAREST 或 Inter.BICUBIC。默认值Inter.BICUBIC。
- **Inter.BILINEAR**:双线性插值。
@ -18,5 +18,5 @@ mindspore.dataset.vision.RandomPerspective
- **TypeError** - 当 `distortion_scale` 的类型不为float。
- **TypeError** - 当 `prob` 的类型不为float。
- **TypeError** - 当 `interpolation` 的类型不为 :class:`mindspore.dataset.vision.Inter`
- **ValueError** - 当 `distortion_scale` 取值不在[0, 1]范围内。
- **ValueError** - 当 `prob` 取值不在[0, 1]范围内。
- **ValueError** - 当 `distortion_scale` 取值不在[0.0, 1.0]范围内。
- **ValueError** - 当 `prob` 取值不在[0.0, 1.0]范围内。

View File

@ -6,7 +6,7 @@ mindspore.dataset.vision.RandomSelectSubpolicy
从策略列表中随机选择一个子策略以应用于输入图像。
参数:
- **policy** (list[list[tuple[TensorOperation, float]]]) - 可供选择的子策略列表。子策略是一系列 (operation, prob) 格式的元组组成的列表,其中 `operation` 是数据处理操作, `prob` 是应用此操作的概率, `prob` 值必须在 [0, 1] 范围内。一旦选择了子策略,子策略中的每个操作都将根据其概率依次应用。
- **policy** (list[list[tuple[TensorOperation, float]]]) - 可供选择的子策略列表。子策略是一系列 (operation, prob) 格式的元组组成的列表,其中 `operation` 是数据处理操作, `prob` 是应用此操作的概率, `prob` 值必须在 [0.0, 1.0] 范围内。一旦选择了子策略,子策略中的每个操作都将根据其概率依次应用。
异常:
- **TypeError** - 当 `policy` 包含无效数据处理操作。

View File

@ -6,9 +6,9 @@ mindspore.dataset.vision.RandomVerticalFlip
以给定的概率对输入图像在垂直方向进行随机翻转。
参数:
- **prob** (float, 可选) - 图像被翻转的概率默认值0.5。
- **prob** (float, 可选) - 图像被翻转的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `prob` 不是float类型。
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围。
- **RuntimeError** - 如果输入的Tensor不是 <H, W> 或 <H, W, C> 格式。
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围。
- **RuntimeError** - 如果输入的Tensor不是 <H, W> 或 <H, W, C> 格式。

View File

@ -6,9 +6,9 @@ mindspore.dataset.vision.RandomVerticalFlipWithBBox
以给定的概率对输入图像和边界框在垂直方向进行随机翻转。
参数:
- **prob** (float, 可选) - 图像被翻转的概率默认值0.5。
- **prob** (float, 可选) - 图像被翻转的概率,取值范围:[0.0, 1.0]。默认值0.5。
异常:
- **TypeError** - 如果 `prob` 不是float类型。
- **ValueError** - 如果 `prob` 不在 [0, 1] 范围。
- **ValueError** - 如果 `prob` 不在 [0.0, 1.0] 范围。
- **RuntimeError** - 如果输入的Tensor不是 <H, W> 或<H, W, C> 格式。

View File

@ -10,3 +10,7 @@
返回:
int输入图像通道数。
异常:
- **RuntimeError** - `image` 参数的维度小于2。
- **TypeError** - `image` 参数的类型既不是 np.ndarray也不是 PIL Image。

View File

@ -10,3 +10,7 @@
返回:
list[int, int],图像大小。
异常:
- **RuntimeError** - `image` 参数的维度小于2。
- **TypeError** - `image` 参数的类型既不是 np.ndarray也不是 PIL Image。

View File

@ -21,7 +21,6 @@
#include "mindspore/core/load_mindir/load_model.h"
#if !defined(_WIN32) && !defined(_WIN64)
#include "cxx_api/dlutils.h"
#include "minddata/dataset/engine/serdes.h"
#include "minddata/dataset/include/dataset/execute.h"
#endif
#include "utils/crypto.h"

View File

@ -504,6 +504,9 @@ class ComputeDeltas(AudioTensorOperation):
.. math::
d_{t}=\frac{{\textstyle\sum_{n=1}^{N}}n(c_{t+n}-c_{t-n})}{2{\textstyle\sum_{n=1}^{N}}n^{2}}
where :math:`d_{t}` is the deltas at time :math:`t` , :math:`c_{t}` is the spectrogram coefficients
at time :math:`t` , :math:`N` is :math:`(\text{win_length}-1)//2` .
Args:
win_length (int, optional): The window length used for computing delta, must be no less than 3 (default=5).
pad_mode (BorderType, optional): Mode parameter passed to padding (default=BorderType.EDGE).It can be any of
@ -1262,10 +1265,15 @@ class MaskAlongAxis(AudioTensorOperation):
Args:
mask_start (int): Starting position of the mask, which must be non negative.
mask_width (int): The width of the mask, which must be non negative.
mask_width (int): The width of the mask, which must be larger than 0.
mask_value (float): Value to assign to the masked columns.
axis (int): Axis to apply masking on (1 for frequency and 2 for time).
Raises:
ValueError: If `mask_start` is invalid (< 0).
ValueError: If `mask_width` is invalid (< 1).
ValueError: If `axis` is not type of integer or not within [1, 2].
Examples:
>>> import numpy as np
>>>
@ -1299,6 +1307,10 @@ class MaskAlongAxisIID(AudioTensorOperation):
mask_value (float): Value to assign to the masked columns.
axis (int): Axis to apply masking on (1 for frequency and 2 for time).
Raises:
ValueError: If `mask_param` is invalid (< 0) or not type of integer.
ValueError: If `axis` is not type of integer or not within [1, 2].
Examples:
>>> import numpy as np
>>>

View File

@ -192,7 +192,7 @@ class ScaleType(str, Enum):
class WindowType(str, Enum):
"""
Window Function types,
Window Function types.
Possible enumeration values are: WindowType.BARTLETT, WindowType.BLACKMAN, WindowType.HAMMING, WindowType.HANN,
WindowType.KAISER.

View File

@ -1174,6 +1174,9 @@ class Dataset:
Returns:
Dataset, dataset zipped.
Raises:
TypeError: The parameter is not dataset object or tuple of dataset objects.
Examples:
>>> # Create a dataset which is the combination of dataset and dataset_1
>>> dataset = dataset.zip(dataset_1)

View File

@ -1588,7 +1588,7 @@ class WikiTextDataset(SourceDataset, TextBaseDataset):
A source dataset that reads and parses WikiText2 and WikiText103 datasets.
The generated dataset has one column :py:obj:`[text]`, and
the tensor of column :py:obj:`text` is of the string type.
the tensor of column `text` is of the string type.
Args:
dataset_dir (str): Path to the root directory that contains the dataset.
@ -1614,9 +1614,13 @@ class WikiTextDataset(SourceDataset, TextBaseDataset):
`Single-Node Data Cache <https://www.mindspore.cn/tutorials/experts/en/master/dataset/cache.html>`_
(default=None, which means no cache is used).
Examples:
>>> wiki_text_dataset_dir = "/path/to/wiki_text_dataset_directory"
>>> dataset = ds.WikiTextDataset(dataset_dir=wiki_text_dataset_dir, usage='all')
Raises:
RuntimeError: If `dataset_dir` does not contain data files or invalid.
ValueError: If `num_samples` is invalid (< 0).
ValueError: If `num_parallel_workers` exceeds the max thread numbers.
RuntimeError: If `num_shards` is specified but `shard_id` is None.
RuntimeError: If `shard_id` is specified but `num_shards` is None.
ValueError: If `shard_id` is invalid (< 0 or >= `num_shards`).
About WikiTextDataset dataset:
@ -1647,6 +1651,10 @@ class WikiTextDataset(SourceDataset, TextBaseDataset):
journal={arXiv preprint arXiv:1609.07843},
year={2016}
}
Examples:
>>> wiki_text_dataset_dir = "/path/to/wiki_text_dataset_directory"
>>> dataset = ds.WikiTextDataset(dataset_dir=wiki_text_dataset_dir, usage='all')
"""
@check_wiki_text_dataset

View File

@ -121,6 +121,7 @@ class JiebaTokenizer(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> from mindspore.dataset.text import JiebaMode
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
>>> jieba_hmm_file = "/path/to/jieba/hmm/file"
@ -175,6 +176,7 @@ class JiebaTokenizer(TextTensorOperation):
the better chance the word will be tokenized (default=None, use default frequency).
Examples:
>>> import mindspore.dataset.text as text
>>> from mindspore.dataset.text import JiebaMode
>>> jieba_hmm_file = "/path/to/jieba/hmm/file"
>>> jieba_mp_file = "/path/to/jieba/mp/file"
@ -292,6 +294,7 @@ class Lookup(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> # Load vocabulary from list
>>> vocab = text.Vocab.from_list(['', '', '', '', ''])
>>> # Use Lookup operation to map tokens to ids
@ -343,6 +346,7 @@ class Ngram(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> ngram_op = text.Ngram(3, separator="-")
>>> output = ngram_op(["WildRose Country", "Canada's Ocean Playground", "Land of Living Skies"])
>>> # output
@ -428,6 +432,7 @@ class SentencePieceTokenizer(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> from mindspore.dataset.text import SentencePieceModel, SPieceTokenizerOutType
>>> sentence_piece_vocab_file = "/path/to/sentence/piece/vocab/file"
>>> vocab = text.SentencePieceVocab.from_file([sentence_piece_vocab_file], 5000, 0.9995,
@ -465,6 +470,7 @@ class SlidingWindow(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset as ds
>>> dataset = ds.NumpySlicesDataset(data=[[1, 2, 3, 4, 5]], column_names="col1")
>>> # Data before
>>> # | col1 |
@ -511,6 +517,8 @@ class ToNumber(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.text as text
>>> from mindspore import dtype as mstype
>>> data = [["1", "2", "3"]]
>>> dataset = ds.NumpySlicesDataset(data)
@ -549,6 +557,7 @@ class ToVectors(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> # Load vectors from file
>>> vectors = text.Vectors.from_file("/path/to/vectors/file")
>>> # Use ToVectors operation to map tokens to vectors
@ -583,6 +592,7 @@ class TruncateSequencePair(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> dataset = ds.NumpySlicesDataset(data={"col1": [[1, 2, 3]], "col2": [[4, 5]]})
>>> # Data before
>>> # | col1 | col2 |
@ -621,6 +631,7 @@ class UnicodeCharTokenizer(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
>>> tokenizer_op = text.UnicodeCharTokenizer(with_offsets=False)
>>> text_file_dataset = text_file_dataset.map(operations=tokenizer_op)
@ -666,6 +677,7 @@ class WordpieceTokenizer(TextTensorOperation):
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> vocab_list = ["book", "cholera", "era", "favor", "##ite", "my", "is", "love", "dur", "##ing", "the"]
>>> vocab = text.Vocab.from_list(vocab_list)
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
@ -744,6 +756,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> from mindspore.dataset.text import NormalizeForm
>>>
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
@ -834,6 +847,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> from mindspore.dataset.text import NormalizeForm
>>>
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
@ -849,8 +863,8 @@ if platform.system().lower() != 'windows':
... with_offsets=False)
>>> text_file_dataset = text_file_dataset.map(operations=tokenizer_op)
>>> # If with_offsets=True, then output three columns {["token", dtype=str],
>>> # ["offsets_start", dtype=uint32],
>>> # ["offsets_limit", dtype=uint32]}
>>> # ["offsets_start", dtype=uint32],
>>> # ["offsets_limit", dtype=uint32]}
>>> tokenizer_op = text.BertTokenizer(vocab=vocab, suffix_indicator='##', max_bytes_per_token=100,
... unknown_token='[UNK]', lower_case=False, keep_whitespace=False,
... normalization_form=NormalizeForm.NONE, preserve_unused_token=True,
@ -897,6 +911,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> case_op = text.CaseFold()
>>> text_file_dataset = text_file_dataset.map(operations=case_op)
"""
@ -917,7 +932,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text.transforms as text
>>> import mindspore.dataset.text as text
>>>
>>> replace_op = text.FilterWikipediaXML()
>>> text_file_dataset = text_file_dataset.map(operations=replace_op)
@ -953,6 +968,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> from mindspore.dataset.text import NormalizeForm
>>> normalize_op = text.NormalizeUTF8(normalize_form=NormalizeForm.NFC)
>>> text_file_dataset = text_file_dataset.map(operations=normalize_op)
@ -994,6 +1010,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> pattern = 'Canada'
>>> replace = 'China'
>>> replace_op = text.RegexReplace(pattern, replace)
@ -1037,6 +1054,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> # If with_offsets=False, default output is one column {["text", dtype=str]}
>>> delim_pattern = r"[ |,]"
>>> tokenizer_op = text.RegexTokenizer(delim_pattern, with_offsets=False)
@ -1080,6 +1098,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
>>> tokenizer_op = text.UnicodeScriptTokenizer(keep_whitespace=True, with_offsets=False)
>>> text_file_dataset = text_file_dataset.map(operations=tokenizer_op)
@ -1121,6 +1140,7 @@ if platform.system().lower() != 'windows':
``CPU``
Examples:
>>> import mindspore.dataset.text as text
>>> # If with_offsets=False, default output one column {["text", dtype=str]}
>>> tokenizer_op = text.WhitespaceTokenizer(with_offsets=False)
>>> text_file_dataset = text_file_dataset.map(operations=tokenizer_op)

View File

@ -36,19 +36,25 @@ class CharNGram(cde.CharNGram):
@check_from_file_vectors
def from_file(cls, file_path, max_vectors=None):
"""
Build a CharNGram vector from a file.
Build a `CharNGram` vector from a file.
Args:
file_path (str): Path of the file that contains the CharNGram vectors.
file_path (str): Path of the file that contains the `CharNGram` vectors.
max_vectors (int, optional): This can be used to limit the number of pre-trained vectors loaded.
Most pre-trained vector sets are sorted in the descending order of word frequency. Thus, in
situations where the entire set doesn't fit in memory, or is not needed for another reason,
passing max_vectors can limit the size of the loaded set (default=None, no limit).
passing `max_vectors` can limit the size of the loaded set (default=None, no limit).
Returns:
CharNGram, CharNGram vector build from a file.
Raises:
RuntimeError: If `file_path` contains invalid data.
ValueError: If `max_vectors` is invalid.
TypeError: If `max_vectors` is not type of integer.
Examples:
>>> from mindspore.dataset import text
>>> char_n_gram = text.CharNGram.from_file("/path/to/char_n_gram/file", max_vectors=None)
"""
@ -73,12 +79,18 @@ class FastText(cde.FastText):
max_vectors (int, optional): This can be used to limit the number of pre-trained vectors loaded.
Most pre-trained vector sets are sorted in the descending order of word frequency. Thus, in
situations where the entire set doesn't fit in memory, or is not needed for another reason,
passing max_vectors can limit the size of the loaded set (default=None, no limit).
passing `max_vectors` can limit the size of the loaded set (default=None, no limit).
Returns:
FastText, FastText vector build from a file.
Raises:
RuntimeError: If `file_path` contains invalid data.
ValueError: If `max_vectors` is invalid.
TypeError: If `max_vectors` is not type of integer.
Examples:
>>> from mindspore.dataset import text
>>> fast_text = text.FastText.from_file("/path/to/fast_text/file", max_vectors=None)
"""
@ -103,12 +115,18 @@ class GloVe(cde.GloVe):
max_vectors (int, optional): This can be used to limit the number of pre-trained vectors loaded.
Most pre-trained vector sets are sorted in the descending order of word frequency. Thus, in
situations where the entire set doesn't fit in memory, or is not needed for another reason,
passing max_vectors can limit the size of the loaded set (default=None, no limit).
passing `max_vectors` can limit the size of the loaded set (default=None, no limit).
Returns:
GloVe, GloVe vector build from a file.
Raises:
RuntimeError: If `file_path` contains invalid data.
ValueError: If `max_vectors` is invalid.
TypeError: If `max_vectors` is not type of integer.
Examples:
>>> from mindspore.dataset import text
>>> glove = text.GloVe.from_file("/path/to/glove/file", max_vectors=None)
"""
@ -220,10 +238,11 @@ class SentencePieceVocab:
SentencePieceVocab, vocab built from the dataset.
Examples:
>>> from mindspore.dataset.text import SentencePieceModel
>>> import mindspore.dataset as ds
>>> from mindspore.dataset.text import SentencePieceVocab, SentencePieceModel
>>> dataset = ds.TextFileDataset("/path/to/sentence/piece/vocab/file", shuffle=False)
>>> vocab = text.SentencePieceVocab.from_dataset(dataset, ["text"], 5000, 0.9995,
... SentencePieceModel.UNIGRAM, {})
>>> vocab = SentencePieceVocab.from_dataset(dataset, ["text"], 5000, 0.9995,
... SentencePieceModel.UNIGRAM, {})
"""
sentence_piece_vocab = cls()
@ -262,9 +281,9 @@ class SentencePieceVocab:
SentencePieceVocab, vocab built from the file.
Examples:
>>> from mindspore.dataset.text import SentencePieceModel
>>> vocab = text.SentencePieceVocab.from_file(["/path/to/sentence/piece/vocab/file"], 5000, 0.9995,
... SentencePieceModel.UNIGRAM, {})
>>> from mindspore.dataset.text import SentencePieceVocab, SentencePieceModel
>>> vocab = SentencePieceVocab.from_file(["/path/to/sentence/piece/vocab/file"], 5000, 0.9995,
... SentencePieceModel.UNIGRAM, {})
"""
sentence_piece_vocab = cls()
@ -284,10 +303,10 @@ class SentencePieceVocab:
filename (str): The name of the file.
Examples:
>>> from mindspore.dataset.text import SentencePieceModel
>>> vocab = text.SentencePieceVocab.from_file(["/path/to/sentence/piece/vocab/file"], 5000, 0.9995,
... SentencePieceModel.UNIGRAM, {})
>>> text.SentencePieceVocab.save_model(vocab, "./", "m.model")
>>> from mindspore.dataset.text import SentencePieceVocab, SentencePieceModel
>>> vocab = SentencePieceVocab.from_file(["/path/to/sentence/piece/vocab/file"], 5000, 0.9995,
... SentencePieceModel.UNIGRAM, {})
>>> SentencePieceVocab.save_model(vocab, "./", "m.model")
"""
cde.SentencePieceVocab.save_model(vocab.c_sentence_piece_vocab, path, filename)
@ -337,12 +356,18 @@ class Vectors(cde.Vectors):
max_vectors (int, optional): This can be used to limit the number of pre-trained vectors loaded.
Most pre-trained vector sets are sorted in the descending order of word frequency. Thus, in
situations where the entire set doesn't fit in memory, or is not needed for another reason,
passing max_vectors can limit the size of the loaded set (default=None, no limit).
passing `max_vectors` can limit the size of the loaded set (default=None, no limit).
Returns:
Vectors, Vectors build from a file.
Raises:
RuntimeError: If `file_path` contains invalid data.
ValueError: If `max_vectors` is invalid.
TypeError: If `max_vectors` is not type of integer.
Examples:
>>> from mindspore.dataset import text
>>> vector = text.Vectors.from_file("/path/to/vectors/file", max_vectors=None)
"""
@ -393,6 +418,8 @@ class Vocab:
Vocab, Vocab object built from the dataset.
Examples:
>>> import mindspore.dataset as ds
>>> from mindspore.dataset import text
>>> dataset = ds.TextFileDataset("/path/to/sentence/piece/vocab/file", shuffle=False)
>>> vocab = text.Vocab.from_dataset(dataset, "text", freq_range=None, top_k=None,
... special_tokens=["<pad>", "<unk>"],
@ -421,6 +448,7 @@ class Vocab:
Vocab, Vocab object built from the list.
Examples:
>>> from mindspore.dataset import text
>>> vocab = text.Vocab.from_list(["w1", "w2", "w3"], special_tokens=["<unk>"], special_first=True)
"""
@ -451,6 +479,7 @@ class Vocab:
Vocab, Vocab object built from the file.
Examples:
>>> from mindspore.dataset import text
>>> # Assume vocab file contains the following content:
>>> # --- begin of file ---
>>> # apple,apple2
@ -488,6 +517,7 @@ class Vocab:
Vocab, Vocab object built from the dict.
Examples:
>>> from mindspore.dataset import text
>>> vocab = text.Vocab.from_dict({"home": 3, "behind": 2, "the": 4, "world": 5, "<unk>": 6})
"""
@ -503,6 +533,7 @@ class Vocab:
A vocabulary consisting of word and id pairs.
Examples:
>>> from mindspore.dataset import text
>>> vocab = text.Vocab.from_list(["word_1", "word_2", "word_3", "word_4"])
>>> vocabory_dict = vocab.vocab()
"""
@ -522,6 +553,7 @@ class Vocab:
The token id or list of token ids.
Examples:
>>> from mindspore.dataset import text
>>> vocab = text.Vocab.from_list(["w1", "w2", "w3"], special_tokens=["<unk>"], special_first=True)
>>> ids = vocab.tokens_to_ids(["w1", "w3"])
"""
@ -545,6 +577,7 @@ class Vocab:
The decoded token(s).
Examples:
>>> from mindspore.dataset import text
>>> vocab = text.Vocab.from_list(["w1", "w2", "w3"], special_tokens=["<unk>"], special_first=True)
>>> token = vocab.ids_to_tokens(0)
"""
@ -569,6 +602,7 @@ def to_bytes(array, encoding='utf8'):
Examples:
>>> import numpy as np
>>> import mindspore.dataset as ds
>>>
>>> data = np.array([["1", "2", "3"]], dtype=np.str_)
>>> dataset = ds.NumpySlicesDataset(data, column_names=["text"])
@ -595,6 +629,7 @@ def to_str(array, encoding='utf8'):
Examples:
>>> import numpy as np
>>> import mindspore.dataset as ds
>>>
>>> data = np.array([["1", "2", "3"]], dtype=np.bytes_)
>>> dataset = ds.NumpySlicesDataset(data, column_names=["text"])

View File

@ -151,7 +151,7 @@ class AdjustGamma(ImageTensorOperation):
The output image pixel value is exponentially related to the input image pixel value.
gamma larger than 1 make the shadows darker,
while gamma smaller than 1 make dark regions lighter.
gain (float, optional): The constant multiplier (default=1).
gain (float, optional): The constant multiplier (default=1.0).
Raises:
TypeError: If `gain` is not of type float.
@ -205,7 +205,7 @@ class AutoAugment(ImageTensorOperation):
- Inter.BICUBIC: means the interpolation method is bicubic interpolation.
- Inter.AREA: means the interpolation method is area interpolation.
- Inter.AREA: means the interpolation method is pixel area interpolation.
fill_value (Union[int, tuple], optional): Pixel fill value for the area outside the transformed image.
It can be an int or a 3-tuple. If it is a 3-tuple, it is used to fill R, G, B channels respectively.
@ -1943,7 +1943,7 @@ class RandomRotation(ImageTensorOperation):
- Inter.BICUBIC, means resample method is bicubic interpolation.
- Inter.AREA: means the interpolation method is area interpolation.
- Inter.AREA: means the interpolation method is pixel area interpolation.
expand (bool, optional): Optional expansion flag (default=False). If set to True, expand the output
image to make it large enough to hold the entire rotated image.

View File

@ -201,7 +201,7 @@ class AdjustGamma(ImageTensorOperation, PyTensorOperation):
The output image pixel value is exponentially related to the input image pixel value.
gamma larger than 1 make the shadows darker,
while gamma smaller than 1 make dark regions lighter.
gain (float, optional): The constant multiplier (default=1).
gain (float, optional): The constant multiplier (default=1.0).
Raises:
TypeError: If `gain` is not of type float.
@ -461,7 +461,7 @@ class AutoAugment(ImageTensorOperation):
- Inter.BICUBIC: means the interpolation method is bicubic interpolation.
- Inter.AREA: means the interpolation method is area interpolation.
- Inter.AREA: means the interpolation method is pixel area interpolation.
fill_value (Union[int, tuple[int]], optional): Pixel fill value for the area outside the transformed image.
It can be an int or a 3-tuple. If it is a 3-tuple, it is used to fill R, G, B channels respectively.
@ -469,8 +469,8 @@ class AutoAugment(ImageTensorOperation):
(default=0).
Raises:
TypeError: If `policy` is not of type AutoAugmentPolicy.
TypeError: If `interpolation` is not of type Inter.
TypeError: If `policy` is not of type :class:`mindspore.dataset.vision.AutoAugmentPolicy`.
TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter`.
TypeError: If `fill_value` is not an integer or a tuple of length 3.
RuntimeError: If given tensor shape is not <H, W, C>.
@ -564,12 +564,12 @@ class BoundingBoxAugment(ImageTensorOperation):
transform (TensorOperation): Transformation operation to be applied on random selection
of bounding box regions of a given image.
ratio (float, optional): Ratio of bounding boxes to apply augmentation on.
Range: [0, 1] (default=0.3).
Range: [0.0, 1.0] (default=0.3).
Raises:
TypeError: If `transform` is an image processing operation in :class:`mindspore.dataset.vision.transforms`.
TypeError: If `ratio` is not of type float.
ValueError: If `ratio` is not in range [0, 1].
ValueError: If `ratio` is not in range [0.0, 1.0].
RuntimeError: If given bounding box is invalid.
Supported Platforms:
@ -781,14 +781,15 @@ class CutMixBatch(ImageTensorOperation):
image_batch_format (ImageBatchFormat): The method of padding. Can be any of
[ImageBatchFormat.NHWC, ImageBatchFormat.NCHW].
alpha (float, optional): Hyperparameter of beta distribution, must be larger than 0 (default = 1.0).
prob (float, optional): The probability by which CutMix is applied to each image, range: [0, 1] (default = 1.0).
prob (float, optional): The probability by which CutMix is applied to each image,
which must be in range: [0.0, 1.0] (default = 1.0).
Raises:
TypeError: If `image_batch_format` is not of type :class:`mindspore.dataset.vision.ImageBatchFormat`.
TypeError: If `alpha` is not of type float.
TypeError: If `prob` is not of type float.
ValueError: If `alpha` is less than or equal 0.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W, C>.
Supported Platforms:
@ -1710,7 +1711,7 @@ class Perspective(ImageTensorOperation, PyTensorOperation):
- Inter.CUBIC: means the interpolation method is bicubic interpolation, here is the same as Inter.BICUBIC.
- Inter.PILCUBIC, means interpolation method is bicubic interpolation like implemented in pillow, input
should be in 3 channels format.(PIL input is not supported)
- Inter.AREA, area interpolation.(PIL input is not supported)
- Inter.AREA, pixel area interpolation.(PIL input is not supported)
Raises:
TypeError: If `start_points` is not of type Sequence[Sequence[int, int]] of length 4.
@ -1812,7 +1813,7 @@ class RandAugment(ImageTensorOperation):
- Inter.BICUBIC: means the interpolation method is bicubic interpolation.
- Inter.AREA: means the interpolation method is area interpolation.
- Inter.AREA: means the interpolation method is pixel area interpolation.
fill_value (Union[int, tuple[int, int, int]], optional): Pixel fill value for the area outside the transformed
image. It can be an int or a 3-tuple. If it is a 3-tuple, it is used to fill R, G, B channels respectively.
@ -1861,13 +1862,13 @@ class RandomAdjustSharpness(ImageTensorOperation):
Degree of 0.0 gives a blurred image, degree of 1.0 gives the original image,
and degree of 2.0 increases the sharpness by a factor of 2.
prob (float, optional): Probability of the image being sharpness adjusted, which
must be in range of [0, 1] (default=0.5).
must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `degree` is not of type float.
TypeError: If `prob` is not of type float.
ValueError: If `degree` is negative.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
Supported Platforms:
@ -2041,7 +2042,7 @@ class RandomAutoContrast(ImageTensorOperation):
ignore (Union[int, sequence], optional): The background pixel values to be ignored, each of
which must be in range of [0, 255] (default=None).
prob (float, optional): Probability of the image being automatically contrasted, which
must be in range of [0, 1] (default=0.5).
must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `cutoff` is not of type float.
@ -2049,7 +2050,7 @@ class RandomAutoContrast(ImageTensorOperation):
TypeError: If `prob` is not of type float.
ValueError: If `cutoff` is not in range [0.0, 50.0).
ValueError: If `ignore` is not in range [0, 255].
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
Supported Platforms:
@ -2482,11 +2483,11 @@ class RandomEqualize(ImageTensorOperation):
Args:
prob (float, optional): Probability of the image being equalized, which
must be in range of [0, 1] (default=0.5).
must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `prob` is not of type float.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
Supported Platforms:
@ -2515,7 +2516,8 @@ class RandomErasing(PyTensorOperation):
See `Random Erasing Data Augmentation <https://arxiv.org/pdf/1708.04896.pdf>`_.
Args:
prob (float, optional): Probability of performing erasing. Default: 0.5.
prob (float, optional): Probability of performing erasing, which
must be in range of [0.0, 1.0] (default: 0.5).
scale (Sequence[float, float], optional): Range of area scale of the erased area relative
to the original image to select from, arranged in order of (min, max).
Default: (0.02, 0.33).
@ -2537,7 +2539,7 @@ class RandomErasing(PyTensorOperation):
TypeError: If `value` is not of type integer, string, or sequence.
TypeError: If `inplace` is not of type boolean.
TypeError: If `max_attempts` is not of type integer.
ValueError: If `prob` is not in range of [0, 1].
ValueError: If `prob` is not in range of [0.0, 1.0].
ValueError: If `scale` is negative.
ValueError: If `ratio` is negative.
ValueError: If `value` is not in range of [0, 255].
@ -2591,11 +2593,12 @@ class RandomGrayscale(PyTensorOperation):
Randomly convert the input PIL Image to grayscale.
Args:
prob (float, optional): Probability of performing grayscale conversion. Default: 0.1.
prob (float, optional): Probability of performing grayscale conversion,
which must be in range of [0.0, 1.0] (default: 0.1).
Raises:
TypeError: If `prob` is not of type float.
ValueError: If `prob` is not in range of [0, 1].
ValueError: If `prob` is not in range of [0.0, 1.0].
Supported Platforms:
``CPU``
@ -2644,11 +2647,12 @@ class RandomHorizontalFlip(ImageTensorOperation, PyTensorOperation):
Randomly flip the input image horizontally with a given probability.
Args:
prob (float, optional): Probability of the image being flipped, which must be in range of [0, 1] (default=0.5).
prob (float, optional): Probability of the image being flipped,
which must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `prob` is not of type float.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
Supported Platforms:
@ -2686,11 +2690,12 @@ class RandomHorizontalFlipWithBBox(ImageTensorOperation):
Flip the input image horizontally randomly with a given probability and adjust bounding boxes accordingly.
Args:
prob (float, optional): Probability of the image being flipped, which must be in range of [0, 1] (default=0.5).
prob (float, optional): Probability of the image being flipped,
which must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `prob` is not of type float.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
Supported Platforms:
@ -2717,11 +2722,12 @@ class RandomInvert(ImageTensorOperation):
Randomly invert the colors of image with a given probability.
Args:
prob (float, optional): Probability of the image being inverted, which must be in range of [0, 1] (default=0.5).
prob (float, optional): Probability of the image being inverted,
which must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `prob` is not of type float.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W, C>.
Supported Platforms:
@ -2792,8 +2798,9 @@ class RandomPerspective(PyTensorOperation):
Randomly apply perspective transformation to the input PIL Image with a given probability.
Args:
distortion_scale (float, optional): Scale of distortion, in range of [0, 1]. Default: 0.5.
prob (float, optional): Probability of performing perspective transformation. Default: 0.5.
distortion_scale (float, optional): Scale of distortion, in range of [0.0, 1.0]. Default: 0.5.
prob (float, optional): Probability of performing perspective transformation, which
must be in range of [0.0, 1.0] (default: 0.5).
interpolation (Inter, optional): Method of interpolation. It can be Inter.BILINEAR,
Inter.NEAREST or Inter.BICUBIC. Default: Inter.BICUBIC.
@ -2805,8 +2812,8 @@ class RandomPerspective(PyTensorOperation):
TypeError: If `distortion_scale` is not of type float.
TypeError: If `prob` is not of type float.
TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter`.
ValueError: If `distortion_scale` is not in range of [0, 1].
ValueError: If `prob` is not in range of [0, 1].
ValueError: If `distortion_scale` is not in range of [0.0, 1.0].
ValueError: If `prob` is not in range of [0.0, 1.0].
Supported Platforms:
``CPU``
@ -3154,7 +3161,7 @@ class RandomRotation(ImageTensorOperation, PyTensorOperation):
- Inter.BICUBIC, means resample method is bicubic interpolation.
- Inter.AREA, means the interpolation method is area interpolation.
- Inter.AREA, means the interpolation method is pixel area interpolation.
expand (bool, optional): Optional expansion flag (default=False). If set to True, expand the output
image to make it large enough to hold the entire rotated image.
@ -3246,7 +3253,7 @@ class RandomSelectSubpolicy(ImageTensorOperation):
Args:
policy (list[list[tuple[TensorOperation, float]]]): List of sub-policies to choose from.
A sub-policy is a list of tuple[operation, prob], where operation is a data processing operation and prob
is the probability that this operation will be applied, and the prob values must be in range [0, 1].
is the probability that this operation will be applied, and the prob values must be in range [0.0, 1.0].
Once a sub-policy is selected, each operation within the sub-policy with be applied in sequence according
to its probability.
@ -3370,11 +3377,12 @@ class RandomVerticalFlip(ImageTensorOperation, PyTensorOperation):
Randomly flip the input image vertically with a given probability.
Args:
prob (float, optional): Probability of the image being flipped. Default=0.5.
prob (float, optional): Probability of the image being flipped, which
must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `prob` is not of type float.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
Supported Platforms:
@ -3412,11 +3420,12 @@ class RandomVerticalFlipWithBBox(ImageTensorOperation):
Flip the input image vertically, randomly with a given probability and adjust bounding boxes accordingly.
Args:
prob (float, optional): Probability of the image being flipped (default=0.5).
prob (float, optional): Probability of the image being flipped,
which must be in range of [0.0, 1.0] (default=0.5).
Raises:
TypeError: If `prob` is not of type float.
ValueError: If `prob` is not in range [0, 1].
ValueError: If `prob` is not in range [0.0, 1.0].
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
Supported Platforms:
@ -4098,7 +4107,7 @@ class TrivialAugmentWide(ImageTensorOperation):
- Inter.BICUBIC: means the interpolation method is bicubic interpolation.
- Inter.AREA: means the interpolation method is area interpolation.
- Inter.AREA: means the interpolation method is pixel area interpolation.
fill_value (Union[int, tuple[int, int, int]], optional): Pixel fill value for the area outside
the transformed image.

View File

@ -393,6 +393,10 @@ def get_image_num_channels(image):
Returns:
int, the number of input image channels.
Raises:
RuntimeError: If `image` has invalid dimensions which should be larger than 1.
TypeError: If `image` is not of type <class 'numpy.ndarray'> or <class 'PIL.Image.Image'>.
Examples:
>>> num_channels = vision.get_image_num_channels(image)
"""
@ -419,6 +423,10 @@ def get_image_size(image):
Returns:
list[int, int], the image size.
Raises:
RuntimeError: If `image` has invalid dimensions which should be larger than 1.
TypeError: If `image` is not of type <class 'numpy.ndarray'> or <class 'PIL.Image.Image'>.
Examples:
>>> image_size = vision.get_image_size(image)
"""