mindspore.numpy.argwhere

mindspore.numpy.argwhere(a)[source]

Find the indices of Tensor elements that are non-zero, grouped by element.

Parameters

a (Union[list, tuple, Tensor]) – Input tensor.

Returns

Tensor. Indices of elements that are non-zero. Indices are grouped by element. This Tensor will have shape \((N, a.ndim)\) where N is the number of non-zero items.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> x = np.array([[[1, 0], [-5, 0]]])
>>> np.argwhere(x)
Tensor(shape=[2, 3], dtype=Int64, value=[[0, 0, 0], [0, 1, 0]])