1

I generate some data in my memory and I want to cast it into numpy.memmap to save up RAM. What should I do? my data is in:

    X_list_total_standardized=np.array(X_list_total_standardized)

I know that I could initialize an empty numpy.memmap:

X_list_total_standardized_memmap=np.memmap(self._prepared_data_location_npmemmap_X,dtype='float32',mode='w+')

What is the most convenient way to store X_list_total_standardized into the memmap? Thank you

PS: would the following command be ok?

    X_list_total_standardized_memmap[:]=X_list_total_standardized[:]

1 Answer 1

5

I found next example in numpy documentation :

data = np.arange(12, dtype='float32')
data.resize((3,4))
fp = np.memmap(filename, dtype='float32', mode='w+', shape=(3,4))
fp[:] = data[:]

So your last command is ok.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.