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
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]]