I am trying to process data and use it later for training a model in keras. However, I am running out of memory while returning 4 arrays at the same time to the main function. The code looks like this:
def prepare_data:
all_3d_data = []
for j in range(all_3d_data):
...
X_train.append(all_3d_data)
del all_3d_data
There are four similar loops in each of which one array is filled with some data. These 4 arrays are returned to the main function at once:
return X_train, Y_train, X_test, Y_test
In the main function when it is called:
if __name__ == "__main__":
X_train, Y_train, X_test,Y_test = prepare_data()
An error raises:
File "C:...\tensorflow\lib\site-packages\numpy\core\numeric.py", line 501, in asarray return array(a, dtype, copy=False, order=order)
MemoryError
This error doesn't happen when I am using smaller data. How can I fix this? Should I use batch in Keras?