Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ tensor 线性代数相关
" :ref:`paddle.t <cn_api_paddle_tensor_t>` ", "对小于等于 2 维的 Tensor 进行数据转置"
" :ref:`paddle.tril <cn_api_tensor_tril>` ", "返回输入矩阵 input 的下三角部分,其余部分被设为 0"
" :ref:`paddle.triu <cn_api_tensor_triu>` ", "返回输入矩阵 input 的上三角部分,其余部分被设为 0"
" :ref:`paddle.triu_indices <_cn_api_tensor_triu_indices>` ", "返回输入矩阵在给定对角线右上三角部分元素坐标"

.. _tensor_manipulation:

Expand Down
29 changes: 29 additions & 0 deletions docs/api/paddle/triu_indices_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. _cn_api_tensor_triu_indices:

triu_indices
--------------------------------

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

返回行数和列数已知的二维矩阵中上三角矩阵元素的行列坐标,坐标的顺序首先按照行号排列,其次按照列号排列,所述上三角矩阵为原始矩阵某一对角线右上部分元素的子矩阵。

参数
:::::::::
- **row** (int) - 输入 x 是描述矩阵的行数的一个 int 类型数值。
- **col** (int,可选) - 输入 x 是描述矩阵的列数的一个 int 类型数值,col 输入默认为 None,此时将 col 设置为 row 的取值,代表输入为正方形矩阵。
- **offset** (int,可选) - 确定所要考虑的对角线的位置,默认值为 0。

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

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

返回
:::::::::
Tensor,返回 row*col 大小矩阵的上三角元素的坐标,其中第一行包含行坐标,第二行包含列坐标

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

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)