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

25 lines
1.1 KiB
ReStructuredText
Raw 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.Tril
=================
.. py:class:: mindspore.nn.Tril
返回一个Tensor指定主对角线以上的元素被置为零。
将矩阵元素沿主对角线分为上三角和下三角(包含对角线)。
参数 `k` 控制对角线的选择。若 `k` 为0则沿主对角线分割并保留下三角所有元素。若 `k` 为正值,则沿主对角线向上选择对角线 `k` ,并保留下三角所有元素。若 `k` 为负值,则沿主对角线向下选择对角线 `k` ,并保留下三角所有元素。
**输入:**
- **x** (Tensor)输入Tensor。数据类型为 `number <https://www.mindspore.cn/docs/api/zh-CN/master/api_python/mindspore.html#mindspore.dtype>`_
- **k** (int)对角线的索引。默认值0。假设输入的矩阵的维度分别为d1d2则k的范围应在[-min(d1, d2)+1, min(d1, d2)-1],超出该范围时输出值与输入 `x` 一致。
**输出:**
Tensor数据类型和shape与 `x` 相同。
**异常:**
- **TypeError** `k` 不是int。
- **ValueError** `x` 的维度小于1。