Received all indexes of elements greater than x in ndarray of size n*n python

Viewed 2313

I have a ndarray of size n*n (200,200).

I want to find all the indexes of the values that greater then 0 and then change them to 1.

I try to do something like that and I received exception.

toggleOn_index = [x for x in  net if x>0]
net[toggleOn_index]=1

What is the most efficient way to do that?

2 Answers
Related