Skip to content
Advertisement

Python 3 causes memory error at shuffle(X,Y) where X is 36000 3-channel images (36000, 256,256,3) and Y is 3-channel normal data (36000, 256,256,3)

Following image showing Memory Usage: Image showing Memory Usage Memory error occurs. I am using Numpy and Python3. I have two numpy arrays of shape (36000,256,256,3) each as X and Y and memory error occurs when I do following code. They are code to prepare training data. Is there another way to do it which uses lesser memory?

This is my processor: Intel® Xeon(R) CPU E5-2620 v4 @ 2.10GHz × 32

The error is shown in : X, Y = shuffle(X,Y)

JavaScript
JavaScript

Advertisement

Answer

It is not clear if this is a custom shuffle function or the numpy.random.shuffle which seems to take in only one array.

If you are running into Out Of Memory error, you should first try sub-sampling your arrays, like X = X[100, :] and Y = Y[100, :], and verify that this is indeed due to exceeding memory.

In order to shuffle two arrays by the same order, I will suggest using numpy.random.permutation which will give you a list of indices.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement