Skip to content

Commit

Permalink
fix some cn_docs format issues (#5277)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
enkilee and SigureMo authored Sep 21, 2022
1 parent c85dfc6 commit 9bedc07
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 125 deletions.
8 changes: 5 additions & 3 deletions docs/api/paddle/clone_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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。

代码示例
:::::::::
Expand Down
30 changes: 11 additions & 19 deletions docs/api/paddle/distribution/IndependentTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


代码示例
Expand All @@ -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)
Expand All @@ -61,7 +53,7 @@ inverse(y)

**返回**

- **x** (Tensor) - 逆变换的计算结果。
Tensor逆变换的计算结果。

forward_log_det_jacobian(x)
'''''''''
Expand All @@ -76,7 +68,7 @@ forward_log_det_jacobian(x)

**返回**

- Tensor - 正变换雅可比行列式绝对值的对数。
Tensor正变换雅可比行列式绝对值的对数。


inverse_log_det_jacobian(y)
Expand All @@ -92,7 +84,7 @@ inverse_log_det_jacobian(y)

**返回**

- Tensor - 逆变换雅可比行列式绝对值的对数。
Tensor逆变换雅可比行列式绝对值的对数。


forward_shape(shape)
Expand All @@ -106,7 +98,7 @@ forward_shape(shape)

**返回**

- Sequence[int] - 正变换输出的形状。
Sequence[int]正变换输出的形状。


inverse_shape(shape)
Expand All @@ -120,4 +112,4 @@ inverse_shape(shape)

**返回**

- Sequence[int] - 逆变换输出的形状。
Sequence[int]逆变换输出的形状。
18 changes: 7 additions & 11 deletions docs/api/paddle/distribution/Multinomial_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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` 时,为分类分布。

多项分布概率密度函数如下:

Expand All @@ -17,18 +16,15 @@ 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` 个分类出现的次数。



参数
:::::::::

- **total_count** (int) - 实验次数。
- **probs** (Tensor) - 每个类别发生的概率。最后一维为事件维度,其它维为批维度。``probs`` 中
的每个元素取值范围为 ``[0,1]``。如果输入数据大于 1,会沿着最后一维进行归一化操作。
- **probs** (Tensor) - 每个类别发生的概率。最后一维为事件维度,其它维为批维度。:attr:`probs` 中的每个元素取值范围为 :math:`[0, 1]`。如果输入数据大于 1,会沿着最后一维进行归一化操作。

代码示例
:::::::::
Expand Down Expand Up @@ -64,7 +60,7 @@ prob(value)

**返回**

- Tensor: value 的概率。
Tensor:attr:`value` 的概率。


log_prob(value)
Expand All @@ -78,7 +74,7 @@ log_prob(value)

**返回**

- Tensor: value 的对数概率。
Tensor:attr:`value` 的对数概率。


sample(shape=())
Expand All @@ -92,4 +88,4 @@ sample(shape=())

**返回**

- Tensor样本数据。
Tensor样本数据。
25 changes: 12 additions & 13 deletions docs/api/paddle/distribution/Normal_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Normal
正态分布

数学公式:
Expand All @@ -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.ndarrayTensor
- **scale** (int|float|list|numpy.ndarray|Tensor) - 正态分布标准差。数据类型为 int、float、list、numpy.ndarrayTensor
- **loc** (int|float|list|numpy.ndarray|Tensor) - 正态分布平均值。数据类型为 float32float64
- **scale** (int|float|list|numpy.ndarray|Tensor) - 正态分布标准差。数据类型为 float32float64
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

代码示例
Expand Down Expand Up @@ -97,7 +96,7 @@ probs(value)

**返回**

Tensor,概率,数据类型与 value 相同。
Tensor,概率,数据类型与 :attr:`value` 相同。

kl_divergence(other)
'''''''''
Expand All @@ -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`:两个平均值之间的差值。

**参数**

Expand Down
20 changes: 11 additions & 9 deletions docs/api/paddle/distribution/PowerTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PowerTransform

.. py:class:: paddle.distribution.PowerTransform(power)
幂变换 :math:`y = x^{power}`
幂变换 :math:`y = x^{power}`。

参数
:::::::::
Expand All @@ -26,43 +26,45 @@ forward(x)

计算正变换 :math:`y=f(x)` 的结果。

有助于将一个随机结果变成另一个随机结果。

**参数**

- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution`
的随机采样结果。

**返回**

- **y** (Tensor) - 正变换的计算结果。
Tensor正变换的计算结果。


inverse(y)
'''''''''

计算逆变换 :math:`x = f^{-1}(y)`
计算逆变换 :math:`x = f^{-1}(y)`

**参数**

- **y** (Tensor) - 逆变换的输入参数。

**返回**

- **x** (Tensor) - 逆变换的计算结果。
Tensor逆变换的计算结果。

forward_log_det_jacobian(x)
'''''''''

计算正变换雅可比行列式绝对值的对数。

如果变换不是一一映射,则雅可比矩阵不存在,返回 ``NotImplementedError`` 。
如果变换不是一一映射,则雅可比矩阵不存在,抛出 ``NotImplementedError`` 。

**参数**

- **x** (Tensor) - 输入参数。

**返回**

- Tensor - 正变换雅可比行列式绝对值的对数。
Tensor正变换雅可比行列式绝对值的对数。


inverse_log_det_jacobian(y)
Expand All @@ -78,7 +80,7 @@ inverse_log_det_jacobian(y)

**返回**

- Tensor - 逆变换雅可比行列式绝对值的对数。
Tensor逆变换雅可比行列式绝对值的对数。


forward_shape(shape)
Expand All @@ -92,7 +94,7 @@ forward_shape(shape)

**返回**

- Sequence[int] - 正变换输出的形状。
Sequence[int]正变换输出的形状。


inverse_shape(shape)
Expand All @@ -106,4 +108,4 @@ inverse_shape(shape)

**返回**

- Sequence[int] - 逆变换输出的形状。
Sequence[int]逆变换输出的形状。
22 changes: 10 additions & 12 deletions docs/api/paddle/distribution/ReshapeTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`` 需要包含相同的元素个数。


参数
Expand All @@ -31,41 +30,40 @@ 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)`

**参数**

- **y** (Tensor) - 逆变换的输入参数。

**返回**

- **x** (Tensor) - 逆变换的计算结果。
Tensor逆变换的计算结果。

forward_log_det_jacobian(x)
'''''''''

计算正变换雅可比行列式绝对值的对数。

如果变换不是一一映射,则雅可比矩阵不存在,返回 ``NotImplementedError``
如果变换不是一一映射,则雅可比矩阵不存在,抛出 ``NotImplementedError``。

**参数**

- **x** (Tensor) - 输入参数。

**返回**

- Tensor - 正变换雅可比行列式绝对值的对数。
Tensor正变换雅可比行列式绝对值的对数。


inverse_log_det_jacobian(y)
Expand All @@ -81,7 +79,7 @@ inverse_log_det_jacobian(y)

**返回**

- Tensor - 逆变换雅可比行列式绝对值的对数。
Tensor逆变换雅可比行列式绝对值的对数。


forward_shape(shape)
Expand All @@ -95,7 +93,7 @@ forward_shape(shape)

**返回**

- Sequence[int] - 正变换输出的形状。
Sequence[int]正变换输出的形状。


inverse_shape(shape)
Expand All @@ -109,4 +107,4 @@ inverse_shape(shape)

**返回**

- Sequence[int] - 逆变换输出的形状。
Sequence[int]逆变换输出的形状。
Loading

0 comments on commit 9bedc07

Please sign in to comment.