aesara.tensor.nonzero(a, return_matrix=False)[source]#

Returns one of the following:

If return_matrix is False (default, same as NumPy):

A tuple of vector arrays such that the ith element of the jth array is the index of the ith non-zero element of the input array in the jth dimension.

If return_matrix is True (same as Aesara Op):

Returns a matrix of shape (ndim, number of nonzero elements) such that element (i,j) is the index in the ith dimension of the jth non-zero element.

  • a (array_like) – Input array.

  • return_matrix (bool) – If True, returns a symbolic matrix. If False, returns a tuple of arrays. Defaults to False.

Return type:

tuple of vectors or matrix

See also


Return the non-zero elements of the input array


Return the indices of the non-zero elements of the flattened input array.