From 8ed45d9212b8b0cf52b54998bde01d2398605544 Mon Sep 17 00:00:00 2001 From: xumengjuan1 Date: Thu, 10 Mar 2022 11:26:08 +0800 Subject: [PATCH] modify apiformat --- docs/api/api_python/mindspore.ops.rst | 11 ----------- docs/api/api_python/mindspore.train.rst | 4 ++++ docs/api/api_python/nn/mindspore.nn.Conv1d.rst | 2 +- docs/api/api_python/nn/mindspore.nn.Perplexity.rst | 2 +- docs/api/api_python/operations.rst | 1 + .../api_python/ops/mindspore.ops.ArgMaxWithValue.rst | 2 +- docs/api/api_python/ops/mindspore.ops.AvgPool.rst | 2 +- docs/api/api_python/ops/mindspore.ops.BatchNorm.rst | 2 +- .../ops/mindspore.ops.ComputeAccidentalHits.rst | 2 +- docs/api/api_python/ops/mindspore.ops.Custom.rst | 6 +++--- docs/api/api_python/ops/mindspore.ops.Dropout2D.rst | 2 +- .../api_python/ops/mindspore.ops.EmbeddingLookup.rst | 4 ++-- docs/api/api_python/ops/mindspore.ops.Flatten.rst | 4 ++-- .../api_python/ops/mindspore.ops.ReverseSequence.rst | 2 +- docs/api/api_python/ops/mindspore.ops.ScatterAdd.rst | 2 +- docs/api/api_python/ops/mindspore.ops.ScatterMax.rst | 2 +- docs/api/api_python/ops/mindspore.ops.ScatterMul.rst | 3 +-- docs/api/api_python/ops/mindspore.ops.ScatterNd.rst | 2 +- docs/api/api_python/ops/mindspore.ops.Stack.rst | 2 +- docs/api/api_python/ops/mindspore.ops.ms_hybrid.rst | 6 +++--- docs/api/api_python/ops/mindspore.ops.tensor_dot.rst | 2 +- .../python/mindspore/ops/operations/array_ops.py | 12 ++++++------ 22 files changed, 35 insertions(+), 42 deletions(-) diff --git a/docs/api/api_python/mindspore.ops.rst b/docs/api/api_python/mindspore.ops.rst index c00e0f28340..313dce5f7d4 100644 --- a/docs/api/api_python/mindspore.ops.rst +++ b/docs/api/api_python/mindspore.ops.rst @@ -399,14 +399,3 @@ functional算子是经过初始化后的Primitive,可以直接作为函数使 mindspore.ops.DataType mindspore.ops.op_info_register mindspore.ops.TBERegOp - -自定义算子 ----------------- - -.. mscnautosummary:: - :toctree: ops - :nosignatures: - :template: classtemplate.rst - - mindspore.ops.Custom - mindspore.ops.ms_hybrid diff --git a/docs/api/api_python/mindspore.train.rst b/docs/api/api_python/mindspore.train.rst index b50fae33018..1862b1df133 100644 --- a/docs/api/api_python/mindspore.train.rst +++ b/docs/api/api_python/mindspore.train.rst @@ -29,6 +29,10 @@ mindspore.train.callback .. include:: train/mindspore.train.callback.SummaryLandscape.rst +.. include:: train/mindspore.train.callback.History.rst + +.. include:: train/mindspore.train.callback.LambdaCallback.rst + .. automodule:: mindspore.train.callback :exclude-members: FederatedLearningManager :members: diff --git a/docs/api/api_python/nn/mindspore.nn.Conv1d.rst b/docs/api/api_python/nn/mindspore.nn.Conv1d.rst index 5e5ce41fc29..d02a99e9bc3 100644 --- a/docs/api/api_python/nn/mindspore.nn.Conv1d.rst +++ b/docs/api/api_python/nn/mindspore.nn.Conv1d.rst @@ -42,7 +42,7 @@ mindspore.nn.Conv1d **输出:** - Tensor,shape为:math:`(N, C_{out}, L_{out})`。 + Tensor,shape为 :math:`(N, C_{out}, L_{out})` 。 pad_mode为"same"时: diff --git a/docs/api/api_python/nn/mindspore.nn.Perplexity.rst b/docs/api/api_python/nn/mindspore.nn.Perplexity.rst index a2198651f76..b1d3d751226 100644 --- a/docs/api/api_python/nn/mindspore.nn.Perplexity.rst +++ b/docs/api/api_python/nn/mindspore.nn.Perplexity.rst @@ -35,7 +35,7 @@ mindspore.nn.Perplexity **参数:** - - **inputs** - 输入 `preds` 和 `labels` 。 `preds` 和 `labels` 是Tensor、list或numpy.ndarray。 `preds` 是预测值, `labels` 是数据的标签。 `preds` 和 `labels` 的shape都是:math:`(N, C)`。 + - **inputs** - 输入 `preds` 和 `labels` 。 `preds` 和 `labels` 是Tensor、list或numpy.ndarray。 `preds` 是预测值, `labels` 是数据的标签。 `preds` 和 `labels` 的shape都是 :math:`(N, C)` 。 **异常:** diff --git a/docs/api/api_python/operations.rst b/docs/api/api_python/operations.rst index f91d06375a6..72d4caf1015 100644 --- a/docs/api/api_python/operations.rst +++ b/docs/api/api_python/operations.rst @@ -410,6 +410,7 @@ distributed_training_ascend.html#id12>`_ 。 :template: classtemplate.rst mindspore.ops.Custom + mindspore.ops.ms_hybrid 其他算子 ^^^^^^^^^^^^^^^ diff --git a/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst b/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst index 9b532626d61..031421c19da 100644 --- a/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst +++ b/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst @@ -21,7 +21,7 @@ **输入:** - - **input_x** (Tensor) - 输入任意维度的Tensor。将输入Tensor的shape设为 :math: `(x_1, x_2, ..., x_N)` 。数据类型为mindspore.float16或float32。 + - **input_x** (Tensor) - 输入任意维度的Tensor。将输入Tensor的shape设为 :math:`(x_1, x_2, ..., x_N)` 。数据类型为mindspore.float16或float32。 **输出:** diff --git a/docs/api/api_python/ops/mindspore.ops.AvgPool.rst b/docs/api/api_python/ops/mindspore.ops.AvgPool.rst index fa012a29708..d95f431a095 100644 --- a/docs/api/api_python/ops/mindspore.ops.AvgPool.rst +++ b/docs/api/api_python/ops/mindspore.ops.AvgPool.rst @@ -13,7 +13,7 @@ mindspore.ops.AvgPool .. warning:: - 支持全局池化。 - - 在Ascend上,"kernel_size"的高度和权重取值为[1, 255]范围内的正整数。 :math: ksize_H * ksize_W < 256。 + - 在Ascend上,"kernel_size"的高度和权重取值为[1, 255]范围内的正整数。 :math:`ksize_H * ksize_W < 256` 。 - 由于指令限制,"strides_h"和"strides_w"的取值为[1, 63]范围内的正整数。 **参数:** diff --git a/docs/api/api_python/ops/mindspore.ops.BatchNorm.rst b/docs/api/api_python/ops/mindspore.ops.BatchNorm.rst index 9e55c2489b1..dc015696156 100644 --- a/docs/api/api_python/ops/mindspore.ops.BatchNorm.rst +++ b/docs/api/api_python/ops/mindspore.ops.BatchNorm.rst @@ -50,7 +50,7 @@ mindspore.ops.BatchNorm - **batch_variance** (Tensor) - 输入的方差,shape为 :math:`(C,)` 的一维Tensor。 - **reserve_space_1** (Tensor) - 需要计算梯度时,被重新使用的均值,shape为 :math:`(C,)` 的一维Tensor。 - **reserve_space_2** (Tensor) - 需要计算梯度时,被重新使用的方差,shape为 :math:`(C,)` 的一维Tensor。 -, + **异常:** - **TypeError:** `is_training` 不是bool。 diff --git a/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst b/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst index d6a47d1bfda..4f6b380130e 100644 --- a/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst +++ b/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst @@ -14,7 +14,7 @@ **输入:** - **true_classes** (Tensor) - 目标类。数据类型为int32或int64,shape为 :math:`(batch\_size, num\_true)` 。 - - **sampled_candidates** (Tensor) - 指定算子的候选采样结果,代表训练样本的类型。其数据类型为int32或int64,shape为 :math: `(num\_sampled, )` 。 + - **sampled_candidates** (Tensor) - 指定算子的候选采样结果,代表训练样本的类型。其数据类型为int32或int64,shape为 :math:`(num\_sampled, )` 。 **输出:** diff --git a/docs/api/api_python/ops/mindspore.ops.Custom.rst b/docs/api/api_python/ops/mindspore.ops.Custom.rst index a874ac2f328..2bf5d83392b 100644 --- a/docs/api/api_python/ops/mindspore.ops.Custom.rst +++ b/docs/api/api_python/ops/mindspore.ops.Custom.rst @@ -3,7 +3,7 @@ mindspore.ops.Custom .. py:class:: mindspore.ops.Custom(exclusive=False, reverse=False) - `Custom`算子是MindSpore自定义算子的统一接口。用户可以利用该接口自行定义MindSpore内置算子库尚未包含的算子。 + `Custom` 算子是MindSpore自定义算子的统一接口。用户可以利用该接口自行定义MindSpore内置算子库尚未包含的算子。 根据输入函数的不用,你可以创建多个自定义算子,并且把它们用在神经网络中。 关于自定义算子的详细说明和介绍,包括参数的正确书写,见编程指南 https://www.mindspore.cn/docs/programming_guide/zh-CN/master/custom_operator_custom.html 。 @@ -28,6 +28,6 @@ mindspore.ops.Custom **异常:** - - **TypeError** - 如果输入`func`不合法,或者`func`对应的注册信息类型不对。 - - **ValueError** - `func_type`的值不在列表内。 + - **TypeError** - 如果输入 `func` 不合法,或者 `func` 对应的注册信息类型不对。 + - **ValueError** - `func_type` 的值不在列表内。 - **ValueError** - 算子注册信息不合法,包括支持平台不匹配,算子输入和属性与函数不匹配。 \ No newline at end of file diff --git a/docs/api/api_python/ops/mindspore.ops.Dropout2D.rst b/docs/api/api_python/ops/mindspore.ops.Dropout2D.rst index 8c79f56f7cc..444b27890b4 100644 --- a/docs/api/api_python/ops/mindspore.ops.Dropout2D.rst +++ b/docs/api/api_python/ops/mindspore.ops.Dropout2D.rst @@ -3,7 +3,7 @@ mindspore.ops.Dropout2D .. py:class:: mindspore.ops.Dropout2D(keep_prob=0.5) - 在训练期间,根据概率 :math:`1 - keep\_prob` ,随机的将一些通道设置为0,且服从伯努利分布。(对于shape为 :math:`(N, C, H, W)` 的四维Tensor,通道特征图指的是shape为 :math:`(H, W)`的二维特征图。) + 在训练期间,根据概率 :math:`1 - keep\_prob` ,随机的将一些通道设置为0,且服从伯努利分布。(对于shape为 :math:`(N, C, H, W)` 的四维Tensor,通道特征图指的是shape为 :math:`(H, W)` 的二维特征图。) 例如,对于批量输入的第 :math:`i_th` 样本的第:math:`j_th` 通道为二维Tensor,即input[i,j]。在前向传播过程中,输入样本的每个通道都有可能被置为0,置为0的概率为 :math:`1 - keep\_prob`,且服从伯努利分布。 diff --git a/docs/api/api_python/ops/mindspore.ops.EmbeddingLookup.rst b/docs/api/api_python/ops/mindspore.ops.EmbeddingLookup.rst index 72de3c479bf..e95bbbbd628 100644 --- a/docs/api/api_python/ops/mindspore.ops.EmbeddingLookup.rst +++ b/docs/api/api_python/ops/mindspore.ops.EmbeddingLookup.rst @@ -9,8 +9,8 @@ mindspore.ops.EmbeddingLookup **输入:** - - **input_params** (Tensor) - shape为 :math: `(x_1, x_2, ..., x_R)` 的Tensor。是一个Tensor切片。当前,只支持二维。 - - **input_indices** (Tensor) - shape为 :math: `(y_1, y_2, ..., y_S)` 的Tensor。指定输入Tensor元素的索引。当取值超出 `input_params` 的范围时,超出部分在输出时填充为0。不支持负值,如果为负值,则结果未定义。其数据类型为int32或int64。 + - **input_params** (Tensor) - shape为 :math:`(x_1, x_2, ..., x_R)` 的Tensor。是一个Tensor切片。当前,只支持二维。 + - **input_indices** (Tensor) - shape为 :math:`(y_1, y_2, ..., y_S)` 的Tensor。指定输入Tensor元素的索引。当取值超出 `input_params` 的范围时,超出部分在输出时填充为0。不支持负值,如果为负值,则结果未定义。其数据类型为int32或int64。 - **offset** (int) - 指定此 `input_params` 切片的偏移值。因此,实际索引等于 `input_indices` 减去 `offset` 。 **输出:** diff --git a/docs/api/api_python/ops/mindspore.ops.Flatten.rst b/docs/api/api_python/ops/mindspore.ops.Flatten.rst index 39074849c34..6ffc6109009 100644 --- a/docs/api/api_python/ops/mindspore.ops.Flatten.rst +++ b/docs/api/api_python/ops/mindspore.ops.Flatten.rst @@ -7,11 +7,11 @@ mindspore.ops.Flatten **输入:** - - **input_x** (Tensor) - 待扁平化的Tensor,其shape为 :math:`(N, \ldots)`, :math: `N` 表示batch size。 + - **input_x** (Tensor) - 待扁平化的Tensor,其shape为 :math:`(N, \ldots)`, :math:`N` 表示batch size。 **输出:** - Tensor,输出shape为 :math:`(N,X)` 的Tensor,其中 :math:`X` 是余下维度的乘积。 + Tensor,输出shape为 :math:`(N, X)` 的Tensor,其中 :math:`X` 是余下维度的乘积。 **异常:** diff --git a/docs/api/api_python/ops/mindspore.ops.ReverseSequence.rst b/docs/api/api_python/ops/mindspore.ops.ReverseSequence.rst index 322ef028ef6..afd68addbe7 100644 --- a/docs/api/api_python/ops/mindspore.ops.ReverseSequence.rst +++ b/docs/api/api_python/ops/mindspore.ops.ReverseSequence.rst @@ -10,7 +10,7 @@ mindspore.ops.ReverseSequence - **seq_dim** (int) - 指定反转的维度,此值为必填参数。 - **batch_dim** (int) - 指定切片维度。默认值:0。 - ** 输入:** + **输入:** - **x** (Tensor) - 输入需反转的数据,其数据类型支持包括bool在内的所有Number类型。 - **seq_lengths** (Tensor) - 指定反转长度,为一维向量,其数据类型为int32或int64。 diff --git a/docs/api/api_python/ops/mindspore.ops.ScatterAdd.rst b/docs/api/api_python/ops/mindspore.ops.ScatterAdd.rst index 58dbe727daf..18eca0daacc 100644 --- a/docs/api/api_python/ops/mindspore.ops.ScatterAdd.rst +++ b/docs/api/api_python/ops/mindspore.ops.ScatterAdd.rst @@ -33,4 +33,4 @@ mindspore.ops.ScatterAdd - **TypeError** - `use_locking` 不是bool。 - **TypeError** - `indices` 不是int32。 - - **ValueError ** - `updates` 的shape不等于 `indices_shape + x_shape[1:]` 。 \ No newline at end of file + - **ValueError** - `updates` 的shape不等于 `indices_shape + x_shape[1:]` 。 \ No newline at end of file diff --git a/docs/api/api_python/ops/mindspore.ops.ScatterMax.rst b/docs/api/api_python/ops/mindspore.ops.ScatterMax.rst index 3a5fa866215..faf40773e3d 100644 --- a/docs/api/api_python/ops/mindspore.ops.ScatterMax.rst +++ b/docs/api/api_python/ops/mindspore.ops.ScatterMax.rst @@ -26,7 +26,7 @@ mindspore.ops.ScatterMax **输出:** - Tensor,更新后的 `input_x `,shape和类型与 `input_x` 相同。 + Tensor,更新后的 `input_x`,shape和类型与 `input_x` 相同。 异常: diff --git a/docs/api/api_python/ops/mindspore.ops.ScatterMul.rst b/docs/api/api_python/ops/mindspore.ops.ScatterMul.rst index c1df3ef5dd5..c628436ec7e 100644 --- a/docs/api/api_python/ops/mindspore.ops.ScatterMul.rst +++ b/docs/api/api_python/ops/mindspore.ops.ScatterMul.rst @@ -1,5 +1,5 @@ - mindspore.ops.ScatterMul +========================= .. py:class:: mindspore.ops.ScatterMul(use_locking=False) @@ -21,7 +21,6 @@ mindspore.ops.ScatterMul - **input_x** (Parameter) - ScatterMul的输入,任意维度的Parameter。 - **indices** (Tensor) - 指定相乘操作的索引,数据类型必须为mindspore.int32。 - **updates** (Tensor) - 指定与 `input_x` 相乘的Tensor,数据类型与 `input_x` 相同,shape为 `indices_shape + x_shape[1:]` 。 - **输出:** diff --git a/docs/api/api_python/ops/mindspore.ops.ScatterNd.rst b/docs/api/api_python/ops/mindspore.ops.ScatterNd.rst index 8185e891b37..4060b63605e 100644 --- a/docs/api/api_python/ops/mindspore.ops.ScatterNd.rst +++ b/docs/api/api_python/ops/mindspore.ops.ScatterNd.rst @@ -17,7 +17,7 @@ mindspore.ops.ScatterNd 在秩为3的第一个维度中插入两个新值矩阵的计算过程如下图所示: - .. image:: api_img/ScatterNd.png + .. image:: ScatterNd.png **输入:** diff --git a/docs/api/api_python/ops/mindspore.ops.Stack.rst b/docs/api/api_python/ops/mindspore.ops.Stack.rst index db800c8edba..847b5f93037 100644 --- a/docs/api/api_python/ops/mindspore.ops.Stack.rst +++ b/docs/api/api_python/ops/mindspore.ops.Stack.rst @@ -24,4 +24,4 @@ **异常:** - **TypeError** - `input_x` 中元素的数据类型不相同。 - - **ValueError** - `input_x` 的长度不大于1,或axis不在[-(R+1),R+1)范围中,或 input_x` 中元素的shape不相同。 \ No newline at end of file + - **ValueError** - `input_x` 的长度不大于1,或axis不在[-(R+1),R+1)范围中,或 `input_x` 中元素的shape不相同。 \ No newline at end of file diff --git a/docs/api/api_python/ops/mindspore.ops.ms_hybrid.rst b/docs/api/api_python/ops/mindspore.ops.ms_hybrid.rst index dd080948a7a..c804dd37fa5 100644 --- a/docs/api/api_python/ops/mindspore.ops.ms_hybrid.rst +++ b/docs/api/api_python/ops/mindspore.ops.ms_hybrid.rst @@ -5,8 +5,8 @@ mindspore.ops.ms_hybrid 用于MindSpore Hybrid DSL函数书写的装饰器。 给用MindSpore Hybrid DSL书写的函数加上此装饰器后,它可以用作一个普通的Python函数。 - 与此同时,他可以用于自定义算子:class:`mindspore.ops.Custom`的输入,其对应的`func_type`可以设置为`hybrid`或者`pyfunc`。 - 使用`hybrid`类型的:class:`mindspore.ops.Custom`自定义算子可以自动推导数据类型和形状。 + 与此同时,他可以用于自定义算子 :class:`mindspore.ops.Custom` 的输入,其对应的 `func_type` 可以设置为 `hybrid` 或者 `pyfunc` 。 + 使用 `hybrid` 类型的 :class:`mindspore.ops.Custom` 自定义算子可以自动推导数据类型和形状。 **参数:** @@ -16,4 +16,4 @@ mindspore.ops.ms_hybrid **输出:** - Function,如果`fn`不是None,那么返回一个用Hybrid DSL写的可执行函数;如果`fn`是None,则返回一个装饰器,该装饰器只有`fn`一个参数。 \ No newline at end of file + Function,如果 `fn` 不是None,那么返回一个用Hybrid DSL写的可执行函数;如果 `fn` 是None,则返回一个装饰器,该装饰器只有 `fn` 一个参数。 \ No newline at end of file diff --git a/docs/api/api_python/ops/mindspore.ops.tensor_dot.rst b/docs/api/api_python/ops/mindspore.ops.tensor_dot.rst index 0a6d31c4038..af509aa7ff8 100644 --- a/docs/api/api_python/ops/mindspore.ops.tensor_dot.rst +++ b/docs/api/api_python/ops/mindspore.ops.tensor_dot.rst @@ -5,7 +5,7 @@ 在任意轴上对Tensor `a` 和 `b` 进行点乘操作。 - 点乘操作可以在指定轴上计算 `a` 和`b` 元素的乘积和。轴数量必须由x1和x2指定,并且该值必须在 `a` 和 `b` 的维度数量的范围内。 + 点乘操作可以在指定轴上计算 `a` 和 `b` 元素的乘积和。轴数量必须由x1和x2指定,并且该值必须在 `a` 和 `b` 的维度数量的范围内。 在两个输入中的选定维度且相互匹配。 diff --git a/mindspore/python/mindspore/ops/operations/array_ops.py b/mindspore/python/mindspore/ops/operations/array_ops.py index 3fc4afbe1d4..e7a07701d05 100755 --- a/mindspore/python/mindspore/ops/operations/array_ops.py +++ b/mindspore/python/mindspore/ops/operations/array_ops.py @@ -1854,8 +1854,8 @@ class ArgMaxWithValue(PrimitiveWithInfer): tensor. - index (Tensor) - The index for the maximum value of the input tensor. If `keep_dims` is true, the shape of - output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`. Otherwise, the shape is - :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)`. + output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`. Otherwise, the shape is + :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` . - output_x (Tensor) - The maximum value of input tensor, with the same shape as index. Raises: @@ -1916,15 +1916,15 @@ class ArgMinWithValue(PrimitiveWithInfer): Inputs: - **input_x** (Tensor) - The input tensor, can be any dimension. Set the shape of input tensor as - :math:`(x_1, x_2, ..., x_N)`. + :math:`(x_1, x_2, ..., x_N)` . Outputs: tuple (Tensor), tuple of 2 tensors, containing the corresponding index and the minimum value of the input tensor. - index (Tensor) - The index for the minimum value of the input tensor. If `keep_dims` is true, the shape of - output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`. Otherwise, the shape is - :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)`. + output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`. Otherwise, the shape is + :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` . - output_x (Tensor) - The minimum value of input tensor, with the same shape as index. Raises: @@ -1977,7 +1977,7 @@ class Tile(PrimitiveWithInfer): Inputs: - **input_x** (Tensor) - 1-D or higher dimensional Tensor. Set the shape of input tensor as - :math:`(x_1, x_2, ..., x_S)`. + :math:`(x_1, x_2, ..., x_S)` . - **multiples** (tuple[int]) - The parameter that specifies the number of replications, the parameter type is tuple, and the data type is int, i.e., :math:`(y_1, y_2, ..., y_S)`.