-
Notifications
You must be signed in to change notification settings - Fork 766
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
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-5161.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 中英文内容上要尽可能保持一致
- 需要在 Overview 中添加索引,可参考 【PaddlePaddle Hackathon 3】5 新增 API bucketize #5089(如果这个函数无法作为 Tensor 一个方法进行访问的话,不需要像那个 PR 一样修改 Tensor 相关的一些内容)
docs/api/paddle/triu_indices_cn.rst
Outdated
|
||
.. py:function:: paddle.triu_indices(row, col, offset=0, dtype='int64') | ||
|
||
返回行数和列数已知的二维矩阵中上三角矩阵元素的行列坐标,其中上三角矩阵为原始矩阵某一对角线右上部分元素的子矩阵。 |
There was a problem hiding this comment.
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.」的翻译
docs/api/paddle/triu_indices_cn.rst
Outdated
::::::::: | ||
- **row** (int) - 输入矩阵的行数。 | ||
- **col** (int) - 输入矩阵的列数。 | ||
- **offset** (int,可选) - 确定从指定二维平面中获取对角线的位置。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里描述感觉和英文不一样呀,另外缺少默认值的描述。
docs/api/paddle/triu_indices_cn.rst
Outdated
+ 如果 offset > 0,取主对角线右上的对角线。 | ||
+ 如果 offset < 0,取主对角线左下的对角线。 | ||
|
||
- **dtype** (int,可选) - 指定输出张量的数据类型,默认值为 int64。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里英文缺少默认值描述,中文缺少数据类型可选值描述。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dtype 的类型怎么会是 int 呢?typo?
docs/api/paddle/triu_indices_cn.rst
Outdated
|
||
返回 | ||
::::::::: | ||
Tensor,二维矩阵的上三角矩阵行坐标和列坐标。数据类型和参数 dtype 一致。 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
上述已修改,关于col是否可以取None的文档部分待讨论后确定最终版本 |
There was a problem hiding this 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 手动修复
docs/api/paddle/triu_indices_cn.rst
Outdated
::::::::: | ||
- **row** (int) - 输入x是描述矩阵的行数的一个int类型数值。 | ||
- **col** (int) - 输入x是描述矩阵的列数的一个int类型数值, | ||
col输入默认为None,此时将col设置为row的取值,代表输入为正方形矩阵。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中文几处折行都已修改,中英文都已补充“可选”
docs/api/paddle/triu_indices_cn.rst
Outdated
+ 如果 offset > 0,取主对角线右上的对角线,所包含的元素减少。 | ||
+ 如果 offset < 0,取主对角线左下的对角线,所排除的元素减少。 | ||
|
||
- **dtype** (str|np.dtype|paddle.dtype,可选) - 指定输出张量的数据类型,默认值为 int64。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里相对于英文缺少可选值的描述
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已补充
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 仍然有代码风格问题,主要是中英文间没有添加空格,可尝试运行上面的命令来修复这两个文件里的问题 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,之后等个预览再看看,估计是没问题了
嗯嗯好的 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job!LGTM
PADDLEPADDLE_PR=45168
PaddlePaddle/Paddle#45168