mars.tensor.argwhere#
- mars.tensor.argwhere(a)[源代码]#
Find the indices of tensor elements that are non-zero, grouped by element.
- 参数
a (array_like) – Input data.
- 返回
index_tensor – Indices of elements that are non-zero. Indices are grouped by element.
- 返回类型
Tensor
提示
mt.argwhere(a)
is the same asmt.transpose(mt.nonzero(a))
.The output of
argwhere
is not suitable for indexing tensors. For this purpose usenonzero(a)
instead.实际案例
>>> import mars.tensor as mt
>>> x = mt.arange(6).reshape(2,3) >>> x.execute() array([[0, 1, 2], [3, 4, 5]]) >>> mt.argwhere(x>1).execute() array([[0, 2], [1, 0], [1, 1], [1, 2]])