mindspore2022/docs/api/api_python/nn/mindspore.nn.Triu.rst

25 lines
900 B
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.nn.Triu
==================
.. py:class:: mindspore.nn.Triu
返回一个Tensor指定主对角线以下的元素被置为0。
将矩阵元素沿主对角线分为上三角和下三角(包含对角线)。
参数 `k` 控制对角线的选择。若 `k` 为0则沿主对角线分割并保留上三角所有元素。若 `k` 为正值,则沿主对角线向上选择对角线 `k` ,并保留上三角所有元素。若 `k` 为负值,则沿主对角线向下选择对角线 `k` ,并保留上三角所有元素。
**输入:**
- **x** (Tensor) - Triu的输入任意维度的Tensor其数据类型为数值型。
- **k** (int) - 对角线的索引。默认值0。
**输出:**
Tensor数据类型和shape与 `x` 相同。
**异常:**
- **TypeError** - `k` 不是int。
- **ValueError** - `x` 的shape长度小于1。