I have a nested for loop. I am trying to implement a function on a numpy array. Sadly, some data point are bad and start taking ram till system freezes. But, i can figure out those faulty indexes manually by interrupting the loop and removing that data.
The the best thing i can think of is executing a time bound 'for' loop where the loop exists when execution time exceeds, say 2 seconds. here is a sample code for my implementation.
channel=6
for index in range(len(X_train)):
for i in range(channel):
X_train[index][:,channel] = function_that_creates_issue_for_some_index_values(X_train[index][]......)