mindspore.numpy.triu_indices_from
- mindspore.numpy.triu_indices_from(arr, k=0)[source]
Returns the indices for the upper-triangle of arr.
- Parameters
- Returns
triu_indices_from, tuple of 2 tensor, shape(N) Indices for the upper-triangle of arr.
- Raises
TypeError – if arr cannot be converted to tensor, or k is not a number.
ValueError – if arr cannot be converted to a 2-dimensional tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> tensor = np.ones((3,3)) >>> print(np.triu_indices_from(tensor)) (Tensor(shape=[6], dtype=Int32, value= [0, 0, 0, 1, 1, 2]), Tensor(shape=[6], dtype=Int32, value= [0, 1, 2, 1, 2, 2]))