I know there is a way to return the index of the maximum element in an array in python: numpy.argmax(). Is there a way to return index of every non-zero element?
For example
array([[ 0., 1., 1., ..., 1., 0., 0.],
[ 0., 1., 1., ..., 1., 0., 1.],
[ 0., 1., 1., ..., 1., 0., 0.],
...,
[ 0., 1., 1., ..., 1., 0., 0.],
[ 0., 1., 1., ..., 1., 0., 0.],
[ 0., 1., 1., ..., 1., 0., 0.]], dtype=float32)
to
[[1, 2, ...,6],
[1,2,...6,8],
...
...
]