mindspore.numpy.tril_indices_from

mindspore.numpy.tril_indices_from(arr, k=0)[源代码]

Returns the indices for the lower-triangle of arr.

参数
  • arr (Union[Tensor, list, tuple]) – 2-dimensional array.

  • k (int, optional) – Diagonal offset, default: 0 .

返回

triu_indices_from, tuple of 2 tensor, shape(N) Indices for the upper-triangle of arr.

异常
  • 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

样例

>>> import mindspore.numpy as np
>>> tensor = np.ones((3,3))
>>> print(np.tril_indices_from(tensor))
(Tensor(shape=[6], dtype=Int32, value= [0, 1, 1, 2, 2, 2]),
 Tensor(shape=[6], dtype=Int32, value= [0, 0, 1, 0, 1, 2]))