nonzero¶
-
paddle.fluid.layers.
nonzero
(input, as_tuple=False)[source] Return a tensor containing the indices of all non-zero elements of the input tensor. If as_tuple is True, return a tuple of 1-D tensors, one for each dimension in input, each containing the indices (in that dimension) of all non-zero elements of input. Given a n-Dimensional input tensor with shape [x_1, x_2, …, x_n], If as_tuple is False, we can get a output tensor with shape [z, n], where z is the number of all non-zero elements in the input tensor. If as_tuple is True, we can get a 1-D tensor tuple of length n, and the shape of each 1-D tensor is [z, 1].
- Parameters
inputs (Variable) – The input tensor variable.
as_tuple (bool) – Return type, Tensor or tuple of Tensor.
- Returns
Variable. The data type is int64.
Examples