mindspore.numpy.argwhere
- mindspore.numpy.argwhere(a)[源代码]
Find the indices of Tensor elements that are non-zero, grouped by element.
- 参数
- 返回
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.
- 异常
TypeError – If input a is not array_like.
ValueError – If dim of a equals to 0.
- Supported Platforms:
Ascend
GPU
CPU
样例
>>> 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]])