mindspore.nn.Triu

class mindspore.nn.Triu[source]

Returns a tensor with elements below 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]]))
>>> triu = nn.Triu()
>>> result = triu(x)
>>> print(result)
[[1 2]
 [0 4]]