Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some cn_docs format issues #5277

Merged
merged 31 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
312c725
fix chinese docs errors
enkilee Sep 15, 2022
11dc538
fix chinese docs errors
enkilee Sep 15, 2022
b72871e
Update clone_cn.rst
enkilee Sep 16, 2022
3cb25f7
Update erfinv_cn.rst
enkilee Sep 16, 2022
1f495b6
Update heaviside_cn.rst
enkilee Sep 16, 2022
021914f
Update heaviside_cn.rst
enkilee Sep 16, 2022
a07fb8d
Update heaviside_cn.rst
enkilee Sep 16, 2022
3c21a94
Update log_loss_cn.rst
enkilee Sep 16, 2022
865f754
Update erfinv_cn.rst
enkilee Sep 16, 2022
9d61505
Update log_loss_cn.rst
SigureMo Sep 17, 2022
db877e7
Update heaviside_cn.rst
SigureMo Sep 17, 2022
3cd788b
Update erfinv_cn.rst
SigureMo Sep 17, 2022
df51b34
Update StackTransform_cn.rst
SigureMo Sep 17, 2022
1f3f1ba
Update grid_sample_cn.rst
SigureMo Sep 17, 2022
0f85867
Update glu_cn.rst
SigureMo Sep 17, 2022
3a6b286
Update clone_cn.rst
SigureMo Sep 17, 2022
fcca32f
Update IndependentTransform_cn.rst
SigureMo Sep 17, 2022
a51ee9d
Update Multinomial_cn.rst
SigureMo Sep 17, 2022
066b359
Update Normal_cn.rst
SigureMo Sep 17, 2022
e68bf48
Update PowerTransform_cn.rst
SigureMo Sep 17, 2022
6683e4f
Update ReshapeTransform_cn.rst
SigureMo Sep 17, 2022
2630167
Update SigmoidTransform_cn.rst
SigureMo Sep 17, 2022
97c450a
Update SoftmaxTransform_cn.rst
SigureMo Sep 17, 2022
99a5aa4
Update StackTransform_cn.rst
SigureMo Sep 17, 2022
60ae141
Update IndependentTransform_cn.rst
SigureMo Sep 17, 2022
e213c11
Update Multinomial_cn.rst
SigureMo Sep 17, 2022
d521a74
Update Normal_cn.rst
SigureMo Sep 17, 2022
0da0ec8
Update PowerTransform_cn.rst
SigureMo Sep 17, 2022
dbf1b0e
Update ReshapeTransform_cn.rst
SigureMo Sep 17, 2022
1d1eb61
Update SigmoidTransform_cn.rst
SigureMo Sep 17, 2022
c263a3a
Update StackTransform_cn.rst
SigureMo Sep 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/paddle/clone_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ clone

参数
:::::::::
- x (Tensor) - 输入 Tensor。
- **x** (Tensor) - 输入 Tensor。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down
9 changes: 4 additions & 5 deletions docs/api/paddle/distribution/IndependentTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ IndependentTransform
``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)``
为 ``(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)`` 。
但 ``forward_log_det_jacobian`` 以及 ``inverse_log_det_jacobian`` 输出形状为 ``(4, 2)`` 。


参数
:::::::::

- **base** (Transform) - 基础变换。
- **reinterpreted_batch_rank** (int) - 被扩展为事件维度的最右侧批维度数量。
- **reinterpreted_batch_rank** (int) - 被扩展为事件维度的最右侧批维度数量,需大于 0


代码示例
Expand Down
5 changes: 2 additions & 3 deletions docs/api/paddle/distribution/Multinomial_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ Multinomial


其中,: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:`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`` 中
- **probs** Tensor) - 每个类别发生的概率。最后一维为事件维度,其它维为批维度。``probs`` 中
的每个元素取值范围为 ``[0,1]``。如果输入数据大于 1,会沿着最后一维进行归一化操作。

代码示例
Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/distribution/Normal_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,15 @@ kl_divergence(other)
上面的数学公式中:

:math:`loc = \mu_0`:当前正态分布的平均值。

:math:`scale = \sigma_0`:当前正态分布的标准差。

:math:`loc = \mu_1`:另一个正态分布的平均值。

:math:`scale = \sigma_1`:另一个正态分布的标准差。

:math:`ratio`:两个标准差之间的比例。

:math:`diff`:两个平均值之间的差值。

**参数**
Expand Down
4 changes: 3 additions & 1 deletion docs/api/paddle/distribution/PowerTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ forward(x)

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

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

**参数**

- **x** (Tensor) - 正变换输入参数,通常为 :ref:`cn_api_distribution_Distribution`
Expand All @@ -39,7 +41,7 @@ forward(x)
inverse(y)
'''''''''

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

**参数**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/distribution/ReshapeTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ forward(x)
inverse(y)
'''''''''

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

**参数**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/distribution/SigmoidTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ forward(x)
inverse(y)
'''''''''

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

**参数**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/distribution/SoftmaxTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ forward(x)
inverse(y)
'''''''''

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

**参数**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/distribution/StackTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ forward(x)
inverse(y)
'''''''''

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

**参数**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/erfinv_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
erfinv
-------------------------------

.. py:function:: paddle.erfinv(x)
.. py:function:: paddle.erfinv(x,Name=None)
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
计算输入矩阵 x 的逆误差函数。
请参考 erf 计算公式 :ref:`cn_api_fluid_layers_erf`

Expand Down
4 changes: 2 additions & 2 deletions docs/api/paddle/heaviside_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ heaviside
.. py:function:: paddle.heaviside(x, y, name=None)


逐元素地对 Tensor `x` 计算由 Tensor `y` 中的对应元素决定的赫维赛德阶跃函数,其计算公式为
`x` 中的每个元素计算由 `y` 中相对应元素决定的赫维赛德阶跃函数,其计算公式为

.. math::
\mathrm{heaviside}(x, y)=
Expand All @@ -19,7 +19,7 @@ heaviside
\right.

.. note::
``paddle.heaviside`` 遵守广播机制,如您想了解更多,请参见 :ref:`cn_user_guide_broadcasting`。
``paddle.heaviside`` 遵守广播机制,如您想了解更多,请参见 :ref:`cn_api_paddle_distributed_broadcast`。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里链接依旧没有正常生成,请 @momozi1996 关注

Copy link
Member

@SigureMo SigureMo Sep 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我前几天看了下,这个 label 是没有定义的,因此无法链接到正确的位置,当然按理说解决方案很简单,就添加一个 label 就行了,但问题是它在 Markdown 文件里

目前 Paddle docs 的 Sphinx 配置采用 recommonmark 进行 Markdown 解析,这个前段时间我想解决部分 Markdown 缩进表格渲染问题(如 API 命名规范 大量缩进表格无法正确渲染)时就发现了

MarkdownParser = parser.CommonMarkParser

recommonmark 确实有很多问题,而且官方也已经不维护了,在置顶 issue 中推荐使用 MyST-Parser 来替代 recommonmark,而且我也不清楚 recommonmark 是否有方法能在 Markdown 中创建 label,至少我在文档中没看到

当然,如果 recommonmark 中有创建 label 的方式,使用该种方式直接在文档中链上即可

readthedoc 文档中明确说明了 MyST-Parser 使用 Markdown 创建 label 的方式,因此我认为也许将 Markdown 解析器换为 MyST-Parser 能彻底解决很多问题

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在这个PR中测试了英文API文档互相引用和API文档中引用其他文档,都可以正常显示,可以参考:PaddlePaddle/Paddle#46347

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样貌似每个 API 都需要单独计算下相对路径吧,如果想要全量修复的话应该挺麻烦的

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对,按目录来改吧,绝对路径不太行,很容易失效,而且没办法随版本走


参数
:::::::::
Expand Down
4 changes: 2 additions & 2 deletions docs/api/paddle/nn/functional/glu_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ glu
::::::::::::

::::::::::
- x (Tensor) - 输入的 ``Tensor``,数据类型为:float32、float64。
- axis (int,可选) - 沿着该轴将输入二等分。D 为输入的维数,则 ``axis`` 应该在 [-D, D) 的范围内。如 ``axis`` 为负数,则相当于 ``axis +D``。
- **x** (Tensor) - 输入的 ``Tensor``,数据类型为:float32、float64。
- **axis** (int,可选) - 沿着该轴将输入二等分。D 为输入的维数,则 ``axis`` 应该在 [-D, D) 的范围内。如 ``axis`` 为负数,则相当于 ``axis +D``。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down
6 changes: 3 additions & 3 deletions docs/api/paddle/nn/functional/grid_sample_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ step 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:

Expand Down Expand Up @@ -66,8 +67,7 @@ step 2:

返回
::::::::::::
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 的特征深度,数据类型与 ``x`` 一致。


代码示例
Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/nn/functional/log_loss_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ log_loss

SigureMo marked this conversation as resolved.
Show resolved Hide resolved
- **input** (Tensor) – 形为 [N x 1] 的二维张量,其中 N 为 batch 大小。该输入是由前驱算子计算得来的概率,数据类型是 float32。
- **label** (Tensor) – 形为 [N x 1] 的二维张量,真值标签,其中 N 为 batch 大小,数据类型是 float32。
- **epsilon** (float) – epsilon
- **epsilon** (float) – 一个很小的数字,以保证数值的稳定性,默认值为 1e-4。
SigureMo marked this conversation as resolved.
Show resolved Hide resolved
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down