mindspore.Tensor.nonzero
- Tensor.nonzero()[source]
Return a Tensor of the positions of all non-zero values.
- Returns
Tensor, a 2-D Tensor whose data type is int64, containing the positions of all non-zero values of the input.
- Supported Platforms:
GPU
Examples
>>> import numpy as np >>> from mindspore import Tensor >>> x = Tensor(np.array([[[1, 0], [-5, 0]]]), mindspore.int32) >>> output = x.nonzero() >>> print(output) [[0 0 0] [0 1 0]]