From a45e2505d0fe5fdf55999314fff7dc49fe30e9ec Mon Sep 17 00:00:00 2001 From: XixinYang Date: Tue, 3 Jan 2023 18:05:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9CumulativeLogsumexp=E4=B8=AD?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E6=96=87=E6=A1=A3=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改CumulativeLogsumexp中英文文档不一致问题 --- .../ops/mindspore.ops.CumulativeLogsumexp.rst | 2 +- .../mindspore/ops/operations/math_ops.py | 35 +++++++++---------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/docs/api/api_python/ops/mindspore.ops.CumulativeLogsumexp.rst b/docs/api/api_python/ops/mindspore.ops.CumulativeLogsumexp.rst index ff4f9b83299..5387d06916a 100644 --- a/docs/api/api_python/ops/mindspore.ops.CumulativeLogsumexp.rst +++ b/docs/api/api_python/ops/mindspore.ops.CumulativeLogsumexp.rst @@ -3,7 +3,7 @@ .. py:class:: mindspore.ops.CumulativeLogsumexp(exclusive=False, reverse=False) - 计算输入 `x` 沿轴 `axis` 的累积LogSumExp函数值。即:若输入 `x` 为[a, b, c],则输出为[a, log(exp(a) + exp(b)), log(exp(a) + exp(b) + exp(c))]。 + 计算输入 `x` 沿轴 `axis` 的累积LogSumExp函数值。即:在参数均为默认值的情况下,若输入 `x` 为[a, b, c],则输出为[a, log(exp(a) + exp(b)), log(exp(a) + exp(b) + exp(c))]。 参数: - **exclusive** (bool, 可选) - 如果为True,将在计算时跳过最后一个元素,此时输出为:[-inf, a, log(exp(a) * exp(b))],其中-inf在输出时出于性能原因将以一个极小负数的形式呈现。默认值:False。 diff --git a/mindspore/python/mindspore/ops/operations/math_ops.py b/mindspore/python/mindspore/ops/operations/math_ops.py index 3d4a87bc9f3..795bb7dfe4b 100644 --- a/mindspore/python/mindspore/ops/operations/math_ops.py +++ b/mindspore/python/mindspore/ops/operations/math_ops.py @@ -664,29 +664,24 @@ class ReduceMean(_Reduce): class CumulativeLogsumexp(Primitive): """ - Compute the cumulative log-sum-exp of the tensor `x` along `axis` . - - When `exclusive` is set `False`, this operation performs an inclusive cumulative log-sum-exp, which means that the - first element of the input is identical to the first element of the output. For example, when takes a tensor - [a, b, c] as input, this operation outputs [a, log(exp(a) + exp(b)), log(exp(a) + exp(b) + exp(c))]. When `reverse` - is set `True`, the cumulative log-sum-exp is performed in the opposite direction and thus get the output - [log(exp(a) + exp(b) + exp(c)), log(exp(b) + exp(c)), c]. - - When `exclusive` is set `True`, this operation performs an exclusive cumulative log-sum-exp instead. For example, - when takes a tensor [a, b, c] as input, this operation outputs [-inf, a, log(exp(a) * exp(b))]. Note that the - neutral element of the log-sum-exp operation is -inf, however, for performance reasons, the minimal value - representable by the floating point type is used instead. When `reverse` is set `True`, the cumulative log-sum-exp - is performed in the opposite direction and thus get the output [log(exp(b) * exp(c)), c, -inf]. + Compute the cumulative log-sum-exp of the input tensor `x` along `axis` . For example, with all parameters at + default values, if the input `x` is a tensor [a, b, c], the output will be [a, log(exp(a) + exp(b)), + log(exp(a) + exp(b) + exp(c))]. Args: - exclusive (bool, optional): If true, perform exclusive cumulative log-sum-exp. - If false, perform inclusive cumulative log-sum-exp. Default: False. - reverse (bool, optional): If true, the cumulative log-sum-exp is performed in the opposite direction. - If false, the cumulative log-sum-exp is performed in the forward direction. Default: False. + exclusive (bool, optional): If true, the last element will be skipped during the calculation and thus an + exclusive cumulative log-sum-exp will be performed. For example, this operation + will output [-inf, a, log(exp(a) * exp(b))] with tensor [a, b, c] as the input. + Note that the minimal value -inf, for performance reasons, is representable by the + floating point type. Default: False. + reverse (bool, optional): If true, the function accumulation values will be calculated after the elements of + `x` on `axis` are flipped, and the calculation result will be flipped afterwards. For + example, this operation will output [log(exp(c) + exp(b) + exp(a)), log(exp(c) + + exp(b)), c] with tensor [a, b, c] as the input. Default: False. Inputs: - - **x** (Tensor) - The input tensor. Must be one of the following types: float16, float32, float64. - The dimension of `x` must greater than 0. + - **x** (Tensor) - The input tensor. Must be one of the following types: float16, float32, float64. The + dimension of `x` must greater than 0. - **axis** (Tensor) - A 0-D tensor describing the dimension to compute the cumulative product. Must be one of the following types: int64, int32, int16. Must be in the range [-rank(x), rank(x)). Default: 0. @@ -7736,6 +7731,7 @@ class SelfAdjointEig(Primitive): [[1. 0.] [0. 1.]] """ + @prim_attr_register def __init__(self, compute_v=True): """Initialize SelfAdjointEig.""" @@ -7886,6 +7882,7 @@ class Ormqr(Primitive): [ -53.659264 -28.157839 -70.42702 ] [ -79.54292 24.00183 -41.34253 ]] """ + @prim_attr_register def __init__(self, left=True, transpose=False): """Initialize Ormqr"""