mindspore.nn.Tril
- class mindspore.nn.Tril[source]
Returns a tensor with elements above the kth diagonal zeroed.
- Inputs:
x (Tensor) - The input tensor.
k (Int) - The index of diagonal. Default: 0
- Outputs:
Tensor, has the same type as input x.
- Raises
TypeError – If k is not an int.
ValueError – If length of shape of x is less than 1.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([[1, 2], [3, 4]])) >>> tril = nn.Tril() >>> result = tril(x) >>> print(result) [[1 0] [3 4]]