I am trying to merge 34 matrices each sized 256 x 6000000
and of type numpy.float32
into a single matrix and store it on my system. Each matrix is stored in a separate .npy
file.
This is the script I am using:
import numpy as np
import os
# combined matrix variable
amp_data = []
count=0
for filename in os.listdir(os.getcwd()):
if filename.endswith('.npy'):
if count==0:
amp_data = np.load(filename, mmap_mode='r')
else:
amp_ = np.load(filename, mmap_mode='r')
amp_data = np.hstack((amp_data, amp_))
del amp_
count = count+1
My system runs into memory error obviously (RAM: 64Gb). Is there way for me to combine these matrices into one and save them?