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

【PaddlePaddle Hackathon 3】13 新增 API triu_indices #5161

Merged
merged 6 commits into from
Aug 25, 2022

Conversation

Rayman96
Copy link
Contributor

PADDLEPADDLE_PR=45168

PaddlePaddle/Paddle#45168

@paddle-bot
Copy link

paddle-bot bot commented Aug 19, 2022

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-5161.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:[Beta]飞桨文档预览工具

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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


.. py:function:: paddle.triu_indices(row, col, offset=0, dtype='int64')

返回行数和列数已知的二维矩阵中上三角矩阵元素的行列坐标,其中上三角矩阵为原始矩阵某一对角线右上部分元素的子矩阵。
Copy link
Member

Choose a reason for hiding this comment

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

中文文档貌似缺失「Indices are ordered based on row and then columns.」的翻译

:::::::::
- **row** (int) - 输入矩阵的行数。
- **col** (int) - 输入矩阵的列数。
- **offset** (int,可选) - 确定从指定二维平面中获取对角线的位置。
Copy link
Member

Choose a reason for hiding this comment

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

这里描述感觉和英文不一样呀,另外缺少默认值的描述。

+ 如果 offset > 0,取主对角线右上的对角线。
+ 如果 offset < 0,取主对角线左下的对角线。

- **dtype** (int,可选) - 指定输出张量的数据类型,默认值为 int64。
Copy link
Member

Choose a reason for hiding this comment

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

这里英文缺少默认值描述,中文缺少数据类型可选值描述。

Copy link
Member

Choose a reason for hiding this comment

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

dtype 的类型怎么会是 int 呢?typo?


返回
:::::::::
Tensor,二维矩阵的上三角矩阵行坐标和列坐标。数据类型和参数 dtype 一致。
Copy link
Member

Choose a reason for hiding this comment

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

这里也和英文不是很一致。

代码示例
:::::::::

COPY-FROM: paddle.triu_indices
Copy link
Member

@SigureMo SigureMo Aug 20, 2022

Choose a reason for hiding this comment

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

示例代码中文没问题,英文那边在只有一个示例代码的情况下不推荐添加 name 属性

      Examples:
          .. code-block:: python
-             :name: triu_indices-example    # 删去 name 行
+                                            # 中间空一行,避免将下一行解析为 rst directive 的属性
              import paddle
              # example 1, default offset value
              data1 = paddle.triu_indices(4,4,0)

@Rayman96
Copy link
Contributor Author

上述已修改,关于col是否可以取None的文档部分待讨论后确定最终版本

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

此外还需要注意下代码风格问题,可以安装 pre-commit 自动修复,如果安装后 commit 时报错可以参考 #5140 手动修复

:::::::::
- **row** (int) - 输入x是描述矩阵的行数的一个int类型数值。
- **col** (int) - 输入x是描述矩阵的列数的一个int类型数值,
col输入默认为None,此时将col设置为row的取值,代表输入为正方形矩阵。
Copy link
Member

@SigureMo SigureMo Aug 23, 2022

Choose a reason for hiding this comment

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

image

中文文档不建议折行,直接跟在后面即可

需要加 ,可选,英文同

Copy link
Contributor Author

Choose a reason for hiding this comment

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

中文几处折行都已修改,中英文都已补充“可选”

+ 如果 offset > 0,取主对角线右上的对角线,所包含的元素减少。
+ 如果 offset < 0,取主对角线左下的对角线,所排除的元素减少。

- **dtype** (str|np.dtype|paddle.dtype,可选) - 指定输出张量的数据类型,默认值为 int64。
Copy link
Member

Choose a reason for hiding this comment

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

这里相对于英文缺少可选值的描述

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已补充

@SigureMo
Copy link
Member

pip install pre-commit==2.17.0
pre-commit run --files docs/api/paddle/Overview_cn.rst
pre-commit run --files docs/api/paddle/triu_indices_cn.rst

仍然有代码风格问题,主要是中英文间没有添加空格,可尝试运行上面的命令来修复这两个文件里的问题

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTM,之后等个预览再看看,估计是没问题了

@Rayman96
Copy link
Contributor Author

LGTM,之后等个预览再看看,估计是没问题了

嗯嗯好的

@Rayman96
Copy link
Contributor Author

LGTM,之后等个预览再看看,估计是没问题了

image

看起来好像可以了

Copy link
Collaborator

@Ligoml Ligoml left a comment

Choose a reason for hiding this comment

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

good job!LGTM

@luotao1 luotao1 merged commit d3ec6b7 into PaddlePaddle:develop Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants