mindspore.numpy.argwhere
- mindspore.numpy.argwhere(a)[源代码]
- 返回Tensor中非零元素的索引,并按元素分组。 - 参数:
- a (Union[list, tuple, Tensor]) - 输入的Tensor。 
 
- 返回:
- Tensor,非零元素的索引。索引按元素分组。Tensor的shape为 \((N, a.ndim)\) 其中 \(N\) 为非零元素个数。 
- 异常:
- TypeError - 如果输入的 - a不是类似数组的对象。
- ValueError - 如果 - a的维数为0。
 
- 支持平台:
- 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]])