From 9bedc072c20aa7875352426a058b7ee4a038be7b Mon Sep 17 00:00:00 2001 From: Infinity_lee Date: Wed, 21 Sep 2022 18:02:55 +0800 Subject: [PATCH] fix some cn_docs format issues (#5277) * fix chinese docs errors * fix chinese docs errors * Update clone_cn.rst fix * Update erfinv_cn.rst fix * Update heaviside_cn.rst fix links * Update heaviside_cn.rst fix links * Update heaviside_cn.rst fix * Update log_loss_cn.rst update * Update erfinv_cn.rst update * Update log_loss_cn.rst * Update heaviside_cn.rst * Update erfinv_cn.rst * Update StackTransform_cn.rst * Update grid_sample_cn.rst * Update glu_cn.rst * Update clone_cn.rst * Update IndependentTransform_cn.rst * Update Multinomial_cn.rst * Update Normal_cn.rst * Update PowerTransform_cn.rst * Update ReshapeTransform_cn.rst * Update SigmoidTransform_cn.rst * Update SoftmaxTransform_cn.rst * Update StackTransform_cn.rst * Update IndependentTransform_cn.rst * Update Multinomial_cn.rst * Update Normal_cn.rst * Update PowerTransform_cn.rst * Update ReshapeTransform_cn.rst * Update SigmoidTransform_cn.rst * Update StackTransform_cn.rst Co-authored-by: Nyakku Shigure --- docs/api/paddle/clone_cn.rst | 8 +++-- .../distribution/IndependentTransform_cn.rst | 30 +++++++------------ .../paddle/distribution/Multinomial_cn.rst | 18 +++++------ docs/api/paddle/distribution/Normal_cn.rst | 25 ++++++++-------- .../paddle/distribution/PowerTransform_cn.rst | 20 +++++++------ .../distribution/ReshapeTransform_cn.rst | 22 +++++++------- .../distribution/SigmoidTransform_cn.rst | 17 +++++------ .../distribution/SoftmaxTransform_cn.rst | 17 +++++------ .../paddle/distribution/StackTransform_cn.rst | 21 +++++++------ docs/api/paddle/erfinv_cn.rst | 4 +-- docs/api/paddle/heaviside_cn.rst | 9 +++--- docs/api/paddle/nn/functional/glu_cn.rst | 11 +++---- .../paddle/nn/functional/grid_sample_cn.rst | 24 +++++++-------- docs/api/paddle/nn/functional/log_loss_cn.rst | 11 ++++--- 14 files changed, 112 insertions(+), 125 deletions(-) diff --git a/docs/api/paddle/clone_cn.rst b/docs/api/paddle/clone_cn.rst index 7ad75edc280..c1fce93d469 100644 --- a/docs/api/paddle/clone_cn.rst +++ b/docs/api/paddle/clone_cn.rst @@ -5,18 +5,20 @@ clone .. py:function:: paddle.clone(x, name=None) -对输入 Tensor ``x`` 进行拷贝,并返回一个新的 Tensor。 +对输入 Tensor :attr:`x` 进行拷贝,并返回一个新的 Tensor。 除此之外,该 API 提供梯度计算,在计算反向时,输出 Tensor 的梯度将会回传给输入 Tensor。 参数 ::::::::: - - x (Tensor) - 输入 Tensor。 + + - **x** (Tensor) - 输入 Tensor。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: -``Tensor``,从输入拷贝的 Tensor + +``Tensor``,从输入 :attr:`x` 拷贝的 Tensor。 代码示例 ::::::::: diff --git a/docs/api/paddle/distribution/IndependentTransform_cn.rst b/docs/api/paddle/distribution/IndependentTransform_cn.rst index 678f7a5a1f6..412fdef0f08 100644 --- a/docs/api/paddle/distribution/IndependentTransform_cn.rst +++ b/docs/api/paddle/distribution/IndependentTransform_cn.rst @@ -6,25 +6,18 @@ IndependentTransform .. py:class:: paddle.distribution.IndependentTransform(base, reinterpreted_batch_rank) - ``IndependentTransform`` 将一个基础变换 ``base`` 的部分批(batch)维度 ``reinterpreted_batch_rank`` 扩展为事件(event)维度。 + ``IndependentTransform`` 将一个基础变换 :attr:`base` 的部分批(batch)维度 ``reinterpreted_batch_rank`` 扩展为事件(event)维度。 - ``IndependentTransform`` 不改变基础变换 ``forward`` 以及 ``inverse`` 计算结果,但会对 - ``forward_log_det_jacobian`` 以及 ``inverse_log_det_jacobian`` 计算结果沿着扩展的维度进行求和。 + ``IndependentTransform`` 不改变基础变换 ``forward`` 以及 ``inverse`` 计算结果,但会对 ``forward_log_det_jacobian`` 以及 ``inverse_log_det_jacobian`` 计算结果沿着扩展的维度进行求和。 -例如,假设基础变换为 ``ExpTransform``,其输入为一个随机采样结果 ``x``,形状 -为 ``(S=[4],B=[2,2],E=[3])`` , ``S`` 、``B`` 、``E`` 分别表示采样形状、批形状、事件形 -状,``reinterpreted_batch_rank=1``。则 ``IndependentTransform(ExpTransform)`` -变换后,``x`` 的形状为 ``(S=[4],B=[2],E=[2,3])``,即将最右侧的批维度作为事件维度。 -此时 ``forward`` 和 ``inverse`` 输出形状仍是 ``(4,2,2,3)`` , -但 ``forward_log_det_jacobian`` 以及 ``inverse_log_det_jacobian`` 输出形状 -为 ``(4, 2)`` 。 +例如,假设基础变换为 ``ExpTransform``,其输入为一个随机采样结果 ``x``,形状为 :math:`(S=[4], B=[2,2], E=[3])` , :math:`S`、:math:`B`、:math:`E` 分别表示采样形状、批形状、事件形状,``reinterpreted_batch_rank=1``。则 ``IndependentTransform(ExpTransform)`` 变换后,``x`` 的形状为 :math:`(S=[4], B=[2], E=[2,3])`,即将最右侧的批维度作为事件维度。此时 ``forward`` 和 ``inverse`` 输出形状仍是 :math:`[4, 2, 2, 3]`,但 ``forward_log_det_jacobian`` 以及 ``inverse_log_det_jacobian`` 输出形状为 :math:`[4, 2]`。 参数 ::::::::: - **base** (Transform) - 基础变换。 -- **reinterpreted_batch_rank** (int) - 被扩展为事件维度的最右侧批维度数量。 +- **reinterpreted_batch_rank** (int) - 被扩展为事件维度的最右侧批维度数量,需大于 0。 代码示例 @@ -42,12 +35,11 @@ forward(x) **参数** -- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` - 的随机采样结果。 +- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` 的随机采样结果。 **返回** -- **y** (Tensor) - 正变换的计算结果。 +Tensor,正变换的计算结果。 inverse(y) @@ -61,7 +53,7 @@ inverse(y) **返回** -- **x** (Tensor) - 逆变换的计算结果。 +Tensor,逆变换的计算结果。 forward_log_det_jacobian(x) ''''''''' @@ -76,7 +68,7 @@ forward_log_det_jacobian(x) **返回** -- Tensor - 正变换雅可比行列式绝对值的对数。 +Tensor,正变换雅可比行列式绝对值的对数。 inverse_log_det_jacobian(y) @@ -92,7 +84,7 @@ inverse_log_det_jacobian(y) **返回** -- Tensor - 逆变换雅可比行列式绝对值的对数。 +Tensor,逆变换雅可比行列式绝对值的对数。 forward_shape(shape) @@ -106,7 +98,7 @@ forward_shape(shape) **返回** -- Sequence[int] - 正变换输出的形状。 +Sequence[int],正变换输出的形状。 inverse_shape(shape) @@ -120,4 +112,4 @@ inverse_shape(shape) **返回** -- Sequence[int] - 逆变换输出的形状。 +Sequence[int],逆变换输出的形状。 diff --git a/docs/api/paddle/distribution/Multinomial_cn.rst b/docs/api/paddle/distribution/Multinomial_cn.rst index b10ada143be..594a2d8ddce 100644 --- a/docs/api/paddle/distribution/Multinomial_cn.rst +++ b/docs/api/paddle/distribution/Multinomial_cn.rst @@ -5,10 +5,9 @@ Multinomial .. py:class:: paddle.distribution.Multinomial(total_count, probs) -``Multinomial`` 表示实验次数为 ``total_count``,概率为 ``probs`` 的多项分布。 +``Multinomial`` 表示实验次数为 :attr:`total_count`,概率为 :attr:`probs` 的多项分布。 -在概率论中,多项分布是二项分布的多元推广,表示具有 :math:`k` 个类别的事件重复实验 :math:`n` -次,每个类别出现次数的概率。当 :math:`k=2` 且 :math:`n=1` 时,为伯努利分布,当 :math:`k=2` 且 :math:`n>1` 时,为二项分布,当 :math:`k>2` 且 :math:`n=1` 时,为分类分布。 +在概率论中,多项分布是二项分布的多元推广,表示具有 :math:`k` 个类别的事件重复实验 :math:`n` 次,每个类别出现次数的概率。当 :math:`k=2` 且 :math:`n=1` 时,为伯努利分布,当 :math:`k=2` 且 :math:`n>1` 时,为二项分布,当 :math:`k>2` 且 :math:`n=1` 时,为分类分布。 多项分布概率密度函数如下: @@ -17,9 +16,7 @@ Multinomial f(x_1, ..., x_k; n, p_1,...,p_k) = \frac{n!}{x_1!...x_k!}p_1^{x_1}...p_k^{x_k} -其中,:math:`n` 表示实验次数,:math:`k` 表示类别数,:math:`p_i` 表示一次实验中,实验结果 -为第 :math:`i` 个类别的概率,需要满足 :math:`{\textstyle \sum_{i=1}^{k}p_i=1}, p_i \ge 0` , - :math:`x_i` 表示第 :math:`i` 个分类出现的次数。 +其中,:math:`n` 表示实验次数,:math:`k` 表示类别数,:math:`p_i` 表示一次实验中,实验结果为第 :math:`i` 个类别的概率,需要满足 :math:`{\textstyle \sum_{i=1}^{k}p_i=1}, p_i \ge 0` , :math:`x_i` 表示第 :math:`i` 个分类出现的次数。 @@ -27,8 +24,7 @@ Multinomial ::::::::: - **total_count** (int) - 实验次数。 -- **probs** (Tensor) - 每个类别发生的概率。最后一维为事件维度,其它维为批维度。``probs`` 中 - 的每个元素取值范围为 ``[0,1]``。如果输入数据大于 1,会沿着最后一维进行归一化操作。 +- **probs** (Tensor) - 每个类别发生的概率。最后一维为事件维度,其它维为批维度。:attr:`probs` 中的每个元素取值范围为 :math:`[0, 1]`。如果输入数据大于 1,会沿着最后一维进行归一化操作。 代码示例 ::::::::: @@ -64,7 +60,7 @@ prob(value) **返回** -- Tensor: value 的概率。 +Tensor,:attr:`value` 的概率。 log_prob(value) @@ -78,7 +74,7 @@ log_prob(value) **返回** -- Tensor: value 的对数概率。 +Tensor,:attr:`value` 的对数概率。 sample(shape=()) @@ -92,4 +88,4 @@ sample(shape=()) **返回** -- Tensor:样本数据。 +Tensor,样本数据。 diff --git a/docs/api/paddle/distribution/Normal_cn.rst b/docs/api/paddle/distribution/Normal_cn.rst index 1b9ff348354..81ee202a037 100644 --- a/docs/api/paddle/distribution/Normal_cn.rst +++ b/docs/api/paddle/distribution/Normal_cn.rst @@ -7,7 +7,6 @@ Normal - 正态分布 数学公式: @@ -20,15 +19,15 @@ Normal 上面的数学公式中: -:math:`loc = \mu`:平均值。 -:math:`scale = \sigma`:标准差。 -:math:`Z`:正态分布常量。 +- :math:`loc = \mu`:平均值; +- :math:`scale = \sigma`:标准差; +- :math:`Z`:正态分布常量。 参数 :::::::::::: - - **loc** (int|float|list|numpy.ndarray|Tensor) - 正态分布平均值。数据类型为 int、float、list、numpy.ndarray 或 Tensor。 - - **scale** (int|float|list|numpy.ndarray|Tensor) - 正态分布标准差。数据类型为 int、float、list、numpy.ndarray 或 Tensor。 + - **loc** (int|float|list|numpy.ndarray|Tensor) - 正态分布平均值。数据类型为 float32 或 float64。 + - **scale** (int|float|list|numpy.ndarray|Tensor) - 正态分布标准差。数据类型为 float32 或 float64。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 代码示例 @@ -97,7 +96,7 @@ probs(value) **返回** -Tensor,概率,数据类型与 value 相同。 +Tensor,概率,数据类型与 :attr:`value` 相同。 kl_divergence(other) ''''''''' @@ -116,12 +115,12 @@ kl_divergence(other) 上面的数学公式中: -:math:`loc = \mu_0`:当前正态分布的平均值。 -:math:`scale = \sigma_0`:当前正态分布的标准差。 -:math:`loc = \mu_1`:另一个正态分布的平均值。 -:math:`scale = \sigma_1`:另一个正态分布的标准差。 -:math:`ratio`:两个标准差之间的比例。 -:math:`diff`:两个平均值之间的差值。 +- :math:`loc = \mu_0`:当前正态分布的平均值; +- :math:`scale = \sigma_0`:当前正态分布的标准差; +- :math:`loc = \mu_1`:另一个正态分布的平均值; +- :math:`scale = \sigma_1`:另一个正态分布的标准差; +- :math:`ratio`:两个标准差之间的比例; +- :math:`diff`:两个平均值之间的差值。 **参数** diff --git a/docs/api/paddle/distribution/PowerTransform_cn.rst b/docs/api/paddle/distribution/PowerTransform_cn.rst index 6b7148ef612..df201623484 100644 --- a/docs/api/paddle/distribution/PowerTransform_cn.rst +++ b/docs/api/paddle/distribution/PowerTransform_cn.rst @@ -5,7 +5,7 @@ PowerTransform .. py:class:: paddle.distribution.PowerTransform(power) -幂变换 :math:`y = x^{power}` 。 +幂变换 :math:`y = x^{power}`。 参数 ::::::::: @@ -26,6 +26,8 @@ forward(x) 计算正变换 :math:`y=f(x)` 的结果。 +有助于将一个随机结果变成另一个随机结果。 + **参数** - **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` @@ -33,13 +35,13 @@ forward(x) **返回** -- **y** (Tensor) - 正变换的计算结果。 +Tensor,正变换的计算结果。 inverse(y) ''''''''' -计算逆变换 :math:`x = f^{-1}(y)` +计算逆变换 :math:`x = f^{-1}(y)`。 **参数** @@ -47,14 +49,14 @@ inverse(y) **返回** -- **x** (Tensor) - 逆变换的计算结果。 +Tensor,逆变换的计算结果。 forward_log_det_jacobian(x) ''''''''' 计算正变换雅可比行列式绝对值的对数。 -如果变换不是一一映射,则雅可比矩阵不存在,返回 ``NotImplementedError`` 。 +如果变换不是一一映射,则雅可比矩阵不存在,抛出 ``NotImplementedError`` 。 **参数** @@ -62,7 +64,7 @@ forward_log_det_jacobian(x) **返回** -- Tensor - 正变换雅可比行列式绝对值的对数。 +Tensor,正变换雅可比行列式绝对值的对数。 inverse_log_det_jacobian(y) @@ -78,7 +80,7 @@ inverse_log_det_jacobian(y) **返回** -- Tensor - 逆变换雅可比行列式绝对值的对数。 +Tensor,逆变换雅可比行列式绝对值的对数。 forward_shape(shape) @@ -92,7 +94,7 @@ forward_shape(shape) **返回** -- Sequence[int] - 正变换输出的形状。 +Sequence[int],正变换输出的形状。 inverse_shape(shape) @@ -106,4 +108,4 @@ inverse_shape(shape) **返回** -- Sequence[int] - 逆变换输出的形状。 +Sequence[int],逆变换输出的形状。 diff --git a/docs/api/paddle/distribution/ReshapeTransform_cn.rst b/docs/api/paddle/distribution/ReshapeTransform_cn.rst index b89d51c3767..785a8810fc5 100644 --- a/docs/api/paddle/distribution/ReshapeTransform_cn.rst +++ b/docs/api/paddle/distribution/ReshapeTransform_cn.rst @@ -5,8 +5,7 @@ ReshapeTransform .. py:class:: paddle.distribution.ReshapeTransform(in_event_shape, out_event_shape) -``ReshapeTransform`` 将输入 Tensor 的事件形状 ``in_event_shape`` 改变为 ``out_event_shape`` 。 -其中,``in_event_shape`` 、 ``out_event_shape`` 需要包含相同的元素个数。 +``ReshapeTransform`` 将输入 Tensor 的事件形状 ``in_event_shape`` 改变为 ``out_event_shape``。其中,``in_event_shape``、``out_event_shape`` 需要包含相同的元素个数。 参数 @@ -31,18 +30,17 @@ forward(x) **参数** -- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` - 的随机采样结果。 +- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` 的随机采样结果。 **返回** -- **y** (Tensor) - 正变换的计算结果。 +Tensor,正变换的计算结果。 inverse(y) ''''''''' -计算逆变换 :math:`x = f^{-1}(y)` +计算逆变换 :math:`x = f^{-1}(y)`。 **参数** @@ -50,14 +48,14 @@ inverse(y) **返回** -- **x** (Tensor) - 逆变换的计算结果。 +Tensor,逆变换的计算结果。 forward_log_det_jacobian(x) ''''''''' 计算正变换雅可比行列式绝对值的对数。 -如果变换不是一一映射,则雅可比矩阵不存在,返回 ``NotImplementedError`` 。 +如果变换不是一一映射,则雅可比矩阵不存在,抛出 ``NotImplementedError``。 **参数** @@ -65,7 +63,7 @@ forward_log_det_jacobian(x) **返回** -- Tensor - 正变换雅可比行列式绝对值的对数。 +Tensor,正变换雅可比行列式绝对值的对数。 inverse_log_det_jacobian(y) @@ -81,7 +79,7 @@ inverse_log_det_jacobian(y) **返回** -- Tensor - 逆变换雅可比行列式绝对值的对数。 +Tensor,逆变换雅可比行列式绝对值的对数。 forward_shape(shape) @@ -95,7 +93,7 @@ forward_shape(shape) **返回** -- Sequence[int] - 正变换输出的形状。 +Sequence[int],正变换输出的形状。 inverse_shape(shape) @@ -109,4 +107,4 @@ inverse_shape(shape) **返回** -- Sequence[int] - 逆变换输出的形状。 +Sequence[int],逆变换输出的形状。 diff --git a/docs/api/paddle/distribution/SigmoidTransform_cn.rst b/docs/api/paddle/distribution/SigmoidTransform_cn.rst index b34e2117879..2704f4f75a7 100644 --- a/docs/api/paddle/distribution/SigmoidTransform_cn.rst +++ b/docs/api/paddle/distribution/SigmoidTransform_cn.rst @@ -23,18 +23,17 @@ forward(x) **参数** -- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` - 的随机采样结果。 +- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` 的随机采样结果。 **返回** -- **y** (Tensor) - 正变换的计算结果。 +Tensor,正变换的计算结果。 inverse(y) ''''''''' -计算逆变换 :math:`x = f^{-1}(y)` +计算逆变换 :math:`x = f^{-1}(y)`。 **参数** @@ -42,7 +41,7 @@ inverse(y) **返回** -- **x** (Tensor) - 逆变换的计算结果。 +Tensor,逆变换的计算结果。 forward_log_det_jacobian(x) ''''''''' @@ -57,7 +56,7 @@ forward_log_det_jacobian(x) **返回** -- Tensor - 正变换雅可比行列式绝对值的对数。 +Tensor,正变换雅可比行列式绝对值的对数。 inverse_log_det_jacobian(y) @@ -73,7 +72,7 @@ inverse_log_det_jacobian(y) **返回** -- Tensor - 逆变换雅可比行列式绝对值的对数。 +Tensor,逆变换雅可比行列式绝对值的对数。 forward_shape(shape) @@ -87,7 +86,7 @@ forward_shape(shape) **返回** -- Sequence[int] - 正变换输出的形状。 +Sequence[int],正变换输出的形状。 inverse_shape(shape) @@ -101,4 +100,4 @@ inverse_shape(shape) **返回** -- Sequence[int] - 逆变换输出的形状。 +Sequence[int],逆变换输出的形状。 diff --git a/docs/api/paddle/distribution/SoftmaxTransform_cn.rst b/docs/api/paddle/distribution/SoftmaxTransform_cn.rst index 55ba1d2394f..d37e4ef4752 100644 --- a/docs/api/paddle/distribution/SoftmaxTransform_cn.rst +++ b/docs/api/paddle/distribution/SoftmaxTransform_cn.rst @@ -10,7 +10,7 @@ Softmax 变换,首先进行 :math:`y = exp(x)` 变换,然后归一化。 Softmax 变换将向量变换为单纯形。 .. note:: -Softmax 不是双射函数,所以 ``forward_log_det_jacobian`` 、 ``inverse_log_det_jacobian`` 未实现。 + Softmax 不是双射函数,所以 ``forward_log_det_jacobian``、``inverse_log_det_jacobian`` 未实现。 代码示例 ::::::::: @@ -27,8 +27,7 @@ forward(x) **参数** -- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` - 的随机采样结果。 +- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` 的随机采样结果。 **返回** @@ -38,7 +37,7 @@ forward(x) inverse(y) ''''''''' -计算逆变换 :math:`x = f^{-1}(y)` +计算逆变换 :math:`x = f^{-1}(y)`。 **参数** @@ -46,7 +45,7 @@ inverse(y) **返回** -- **x** (Tensor) - 逆变换的计算结果。 +Tensor,逆变换的计算结果。 forward_log_det_jacobian(x) ''''''''' @@ -61,7 +60,7 @@ forward_log_det_jacobian(x) **返回** -- Tensor - 正变换雅可比行列式绝对值的对数。 +Tensor,正变换雅可比行列式绝对值的对数。 inverse_log_det_jacobian(y) @@ -77,7 +76,7 @@ inverse_log_det_jacobian(y) **返回** -- Tensor - 逆变换雅可比行列式绝对值的对数。 +Tensor,逆变换雅可比行列式绝对值的对数。 forward_shape(shape) @@ -91,7 +90,7 @@ forward_shape(shape) **返回** -- Sequence[int] - 正变换输出的形状。 +Sequence[int],正变换输出的形状。 inverse_shape(shape) @@ -105,4 +104,4 @@ inverse_shape(shape) **返回** -- Sequence[int] - 逆变换输出的形状。 +Sequence[int],逆变换输出的形状。 diff --git a/docs/api/paddle/distribution/StackTransform_cn.rst b/docs/api/paddle/distribution/StackTransform_cn.rst index d7be31bd51c..fc8eb80cff0 100644 --- a/docs/api/paddle/distribution/StackTransform_cn.rst +++ b/docs/api/paddle/distribution/StackTransform_cn.rst @@ -11,7 +11,7 @@ StackTransform ::::::::: - **transforms** (Sequence[Transform]) - 变换序列。 -- **axis** (int,可选) - 待变换的轴,默认值:0,表示沿着第 0 个轴变换。 +- **axis** (int,可选) - 待变换的轴,默认值为 0,表示沿着第 0 个轴变换。 代码示例 ::::::::: @@ -28,18 +28,17 @@ forward(x) **参数** -- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` - 的随机采样结果。 +- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution` 的随机采样结果。 **返回** -- **y** (Tensor) - 正变换的计算结果。 +Tensor,正变换的计算结果。 inverse(y) ''''''''' -计算逆变换 :math:`x = f^{-1}(y)` +计算逆变换 :math:`x = f^{-1}(y)`。 **参数** @@ -47,14 +46,14 @@ inverse(y) **返回** -- **x** (Tensor) - 逆变换的计算结果。 +Tensor,逆变换的计算结果。 forward_log_det_jacobian(x) ''''''''' 计算正变换雅可比行列式绝对值的对数。 -如果变换不是一一映射,则雅可比矩阵不存在,返回 ``NotImplementedError`` 。 +如果变换不是一一映射,则雅可比矩阵不存在,抛出 ``NotImplementedError``。 **参数** @@ -62,7 +61,7 @@ forward_log_det_jacobian(x) **返回** -- Tensor - 正变换雅可比行列式绝对值的对数。 +Tensor,正变换雅可比行列式绝对值的对数。 inverse_log_det_jacobian(y) @@ -78,7 +77,7 @@ inverse_log_det_jacobian(y) **返回** -- Tensor - 逆变换雅可比行列式绝对值的对数。 +Tensor,逆变换雅可比行列式绝对值的对数。 forward_shape(shape) @@ -92,7 +91,7 @@ forward_shape(shape) **返回** -- Sequence[int] - 正变换输出的形状。 +Sequence[int],正变换输出的形状。 inverse_shape(shape) @@ -106,4 +105,4 @@ inverse_shape(shape) **返回** -- Sequence[int] - 逆变换输出的形状。 +Sequence[int],逆变换输出的形状。 diff --git a/docs/api/paddle/erfinv_cn.rst b/docs/api/paddle/erfinv_cn.rst index 72d20c70ceb..8da17f7548e 100644 --- a/docs/api/paddle/erfinv_cn.rst +++ b/docs/api/paddle/erfinv_cn.rst @@ -3,7 +3,7 @@ erfinv ------------------------------- -.. py:function:: paddle.erfinv(x) +.. py:function:: paddle.erfinv(x, name=None) 计算输入矩阵 x 的逆误差函数。 请参考 erf 计算公式 :ref:`cn_api_fluid_layers_erf` @@ -19,7 +19,7 @@ erfinv 返回 ::::::::: -输出 Tensor,与 ``x`` 数据类型相同。 +输出 Tensor,与 :attr:`x` 数据类型相同。 代码示例 ::::::::: diff --git a/docs/api/paddle/heaviside_cn.rst b/docs/api/paddle/heaviside_cn.rst index 2b8eb7215f5..834567c5b19 100644 --- a/docs/api/paddle/heaviside_cn.rst +++ b/docs/api/paddle/heaviside_cn.rst @@ -6,7 +6,7 @@ heaviside .. py:function:: paddle.heaviside(x, y, name=None) -逐元素地对 Tensor `x` 计算由 Tensor `y` 中的对应元素决定的赫维赛德阶跃函数,其计算公式为 +为 :attr:`x` 中的每个元素计算由 :attr:`y` 中相对应元素决定的赫维赛德阶跃函数,其计算公式为 .. math:: \mathrm{heaviside}(x, y)= @@ -23,13 +23,14 @@ heaviside 参数 ::::::::: - - **x** (Tensor)- 赫维赛德阶跃函数的输入 Tensor。数据类型为 float16、float32、float64、int32 或 int64。 - - **y** (Tensor)- 决定了一个赫维赛德阶跃函数的 Tensor。数据类型为 float16、float32、float64、int32 或 int64。 + - **x** (Tensor) - 赫维赛德阶跃函数的输入 Tensor。数据类型为 float16、float32、float64、int32 或 int64。 + - **y** (Tensor) - 决定了一个赫维赛德阶跃函数的 Tensor。数据类型为 float16、float32、float64、int32 或 int64。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: - `Tensor`,存储运算后的结果。如果 `x` 和 `y` 有不同的形状且是可以广播的,那么返回 Tensor 的形状是 `x` 和 `y` 经过广播后的形状。如果 `x` 和 `y` 有相同的形状,那么返回 Tensor 的形状与 `x` 和 `y` 相同。 + +`Tensor`,存储运算后的结果。如果 :attr:`x` 和 :attr:`y` 有不同的形状且是可以广播的,那么返回 Tensor 的形状是 :attr:`x` 和 :attr:`y` 经过广播后的形状。如果 :attr:`x` 和 :attr:`y` 有相同的形状,那么返回 Tensor 的形状与 :attr:`x` 和 :attr:`y` 相同。 代码示例 diff --git a/docs/api/paddle/nn/functional/glu_cn.rst b/docs/api/paddle/nn/functional/glu_cn.rst index 10f7de9099f..284adfa6d14 100644 --- a/docs/api/paddle/nn/functional/glu_cn.rst +++ b/docs/api/paddle/nn/functional/glu_cn.rst @@ -5,8 +5,7 @@ glu .. py:function:: paddle.nn.functional.glu(x, axis=-1, name=None) -门控线性单元。输入按照给定的维度二等分,其中第一部分被用作内容,第二部分经过一个 sigmoid 函数 -之后被用作门限。输入是内容和门限的逐元素乘积。 +门控线性单元。输入按照给定的维度二等分,其中第一部分被用作内容,第二部分经过一个 sigmoid 函数之后被用作门限。输入是内容和门限的逐元素乘积。 .. math:: \mathrm{GLU}(a, b) = a \otimes \sigma(b) @@ -15,14 +14,16 @@ glu :::::::::::: :::::::::: - - x (Tensor) - 输入的 ``Tensor``,数据类型为:float32、float64。 - - axis (int,可选) - 沿着该轴将输入二等分。D 为输入的维数,则 ``axis`` 应该在 [-D, D) 的范围内。如 ``axis`` 为负数,则相当于 ``axis +D``。 + - **x** (Tensor) - 输入的 ``Tensor``,数据类型为 float32 或 float64。 + - **axis** (int,可选) - 沿着该轴将输入二等分。:math:`D` 为输入的维数,则 :attr:`axis` 应该在 :math:`[-D, D)` 的范围内。如 :attr:`axis` 为负数,则相当于 :math:`axis + D`。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 :::::::::: - ``Tensor``,数据类型同 ``x`` 一致,在指定的轴上其尺寸减半。 + +``Tensor``,数据类型同 :attr:`x` 一致,在指定的轴上其尺寸减半。 代码示例 :::::::::: + COPY-FROM: paddle.nn.functional.glu diff --git a/docs/api/paddle/nn/functional/grid_sample_cn.rst b/docs/api/paddle/nn/functional/grid_sample_cn.rst index 3391dd03675..d7d9ff0ff7e 100644 --- a/docs/api/paddle/nn/functional/grid_sample_cn.rst +++ b/docs/api/paddle/nn/functional/grid_sample_cn.rst @@ -8,22 +8,22 @@ grid_sample -基于 flow field 网格的对输入 X 进行双线性插值采样。网格通常由 affine_grid 生成,当输入 X 为 4 维时,网格 shape 为[N, H, W, 2],是 shape 为[N, H, W]的采样点张量的(x, y)坐标。 -其中,x 坐标是对输入数据 X 的第四个维度(宽度维度)的索引,y 坐标是第三维度(高维度)的索引,最终输出采样值为采样点的 4 个最接近的角点的双线性插值结果,输出张量的 shape 为[N, C, H, W]。 -当输入 X 为 5 维时,网格 shape 为[N, D, H, W, 3],是 shape 为[N, D, H, W]的采样点张量的(x, y, z)坐标。其中,x 坐标是对输入数据 X 的第五个维度(宽度维度)的索引,y 坐标是第四维度 -(高度维度)的索引,z 坐标是对输入数据 X 的第三个维度(深度维度)的索引,最终输出采样值为采样点的 8 个最接近的角点的双线性插值结果,输出张量的 shape 为[N, C, D, H, W]。 +基于 flow field 网格的对输入 X 进行双线性插值采样。网格通常由 affine_grid 生成,当输入 X 为 4 维时,网格 shape 为 :math:`[N, H, W, 2]`,是 shape 为 :math:`[N, H, W]` 的采样点张量的 (x, y) 坐标。 +其中,x 坐标是对输入数据 X 的第四个维度(宽度维度)的索引,y 坐标是第三维度(高维度)的索引,最终输出采样值为采样点的 4 个最接近的角点的双线性插值结果,输出张量的 shape 为 :math:`[N, C, H, W]`。 +当输入 X 为 5 维时,网格 shape 为 :math:`[N, D, H, W, 3]`,是 shape 为 :math:`[N, D, H, W]` 的采样点张量的 (x, y, z) 坐标。其中,x 坐标是对输入数据 X 的第五个维度(宽度维度)的索引,y 坐标是第四维度(高度维度)的索引,z 坐标是对输入数据 X 的第三个维度(深度维度)的索引,最终输出采样值为采样点的 8 个最接近的角点的双线性插值结果,输出张量的 shape 为 :math:`[N, C, D, H, W]`。 step 1: - 得到(x, y)网格坐标,缩放到[0,h -1/W-1] + 得到 (x, y) 网格坐标,缩放到 :math:`[0, \frac{h-1}{W-1}]`。 .. code-block:: text - grid_x = 0.5 * (grid[:, :, :, 0] + 1) * (W - 1) grid_y = 0.5 * (grid[:, :, :, 1] + 1) * (H - 1) + grid_x = 0.5 * (grid[:, :, :, 0] + 1) * (W - 1) + grid_y = 0.5 * (grid[:, :, :, 1] + 1) * (H - 1) step 2: - 在每个[H, W]区域用网格(X, y)作为输入数据 X 的索引,并将双线性插值点值由 4 个最近的点表示。 + 在每个 :math:`[H, W]` 区域用网格 (X, y) 作为输入数据 X 的索引,并将双线性插值点值由 4 个最近的点表示。 .. code-block:: text @@ -59,15 +59,15 @@ step 2: - **x** (Tensor) - 输入张量,维度为 :math:`[N, C, H, W]` 的 4-D Tensor 或维度为 :math:`[N, C, D, H, W]` 的 5-D Tensor,N 为批尺寸,C 是通道数,D 是特征深度,H 是特征高度,W 是特征宽度,数据类型为 float32 或 float64。 - **grid** (Tensor) - 输入网格数据张量,维度为 :math:`[N, H, W, 2]` 的 4-D Tensor 或维度为 :math:`[N, D, H, W, 3]` 的 5-D Tensor,N 为批尺寸,H 是特征高度,D 是特征深度,W 是特征宽度,数据类型为 float32 或 float64。 - - **mode** (str,可选) - 插值方式,可以为 'bilinear' 或者 'nearest'。默认值:'bilinear'。 - - **padding_mode** (str,可选) - 当原来的索引超过输入的图像大小时的填充方式。可以为 'zeros', 'reflection' 和 'border'。默认值:'zeros'。 - - **align_corners** (bool,可选) - 一个可选的 bool 型参数,如果为 True,则将输入和输出张量的 4 个或 8 个角落像素的中心对齐,并保留角点像素的值。默认值:True。 + - **mode** (str,可选) - 插值方式,可以为 'bilinear' 或者 'nearest'。默认值为 'bilinear'。 + - **padding_mode** (str,可选) - 当原来的索引超过输入的图像大小时的填充方式。可以为 'zeros', 'reflection' 和 'border'。默认值为 'zeros'。 + - **align_corners** (bool,可选) - 一个可选的 bool 型参数,如果为 True,则将输入和输出张量的 4 个或 8 个角落像素的中心对齐,并保留角点像素的值。默认值为 True。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 :::::::::::: -Tensor,输入 X 基于输入网格的双线性插值计算结果,维度为 :math:`[N, C, H, W]` 的 4-D Tensor 或维度为 :math:`[N, C, D, H, W]` 的 5-D Tensor, -数据类型与 ``x`` 一致。 + +Tensor,输入 X 基于输入网格的双线性插值计算结果,维度为 :math:`[N, C, H, W]` 的 4-D Tensor 或维度为 :math:`[N, C, D, H, W]` 的 5-D Tensor, grid_H 是 grid 的特征高度, grid_W 是 grid 的特征深度,数据类型与 :attr:`x` 一致。 代码示例 diff --git a/docs/api/paddle/nn/functional/log_loss_cn.rst b/docs/api/paddle/nn/functional/log_loss_cn.rst index 464e268bcc9..c3f89790d8c 100644 --- a/docs/api/paddle/nn/functional/log_loss_cn.rst +++ b/docs/api/paddle/nn/functional/log_loss_cn.rst @@ -10,7 +10,7 @@ log_loss **负 log loss 层** -该 OP 对输入的预测结果和目标标签进行计算,返回负对数损失值。 +对输入的预测结果和目标标签进行计算,返回负对数损失值。 .. math:: @@ -20,16 +20,15 @@ log_loss 参数 :::::::::::: - - **input** (Tensor) – 形为 [N x 1] 的二维张量,其中 N 为 batch 大小。该输入是由前驱算子计算得来的概率,数据类型是 float32。 - - **label** (Tensor) – 形为 [N x 1] 的二维张量,真值标签,其中 N 为 batch 大小,数据类型是 float32。 - - **epsilon** (float) – epsilon + - **input** (Tensor) – 形为 :math:`[N, 1]` 的二维张量,其中 :math:`N` 为 batch 大小。该输入是由前驱算子计算得来的概率,数据类型是 float32。 + - **label** (Tensor) – 形为 :math:`[N, 1]` 的二维张量,真值标签,其中 :math:`N` 为 batch 大小,数据类型是 float32。 + - **epsilon** (float,可选) – 一个很小的数字,以保证数值的稳定性,默认值为 1e-4。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 :::::::::::: - Tensor,形状为[N x 1],数据类型为 float32 - +Tensor,形状为 :math:`[N, 1]`,数据类型为 float32。 代码示例 ::::::::::::