numpy.reshape breaks when dealing with an array of a big size

Viewed 21

I have an initial NumPy array of size (512,512,100) of type np.float64 and then I use view_as_windows function to get an array of size (499,499,100,64,64). This function returns a view that consumes much less memory than an actual NumPy array. I want to reshape the view to (499*499*100,64,64). Using the regular np.reshape function, it takes too much time trying to reshape the array, and then it breaks due to trying to convert it to an actual NumPy array. I tried the following, and none of them works:

#gs.shape gives (499,499,100,64,64)
gs.shape = (gs.shape[0]*gs.shape[1]*gs.shape[2],64,64,)
gs = np.reshape(gs,(gs.shape[0]*gs.shape[1]*gs.shape[2],64,64,))
gs = gs.reshape(gs.shape[0]*gs.shape[1]*gs.shape[2],64,64,)

What is the correct way to change the view without actually causing memory overload?

0 Answers
Related