mars.tensor.
argwhere
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
参见
where, nonzero
where
nonzero
提示
mt.argwhere(a) is the same as mt.transpose(mt.nonzero(a)).
mt.argwhere(a)
mt.transpose(mt.nonzero(a))
The output of argwhere is not suitable for indexing tensors. For this purpose use nonzero(a) instead.
nonzero(a)
实际案例
>>> 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]])