Reputation: 19
I have this code,
size_of_similarity_M =80000
similarity_M = numpy.empty((size_of_similarity_M,size_of_similarity_M))
And I am getting this error:
Traceback (most recent call last):
File "<ipython-input-1337-7f9234015aae>", line 1, in <module>
runfile('C:/Users/cp1/PythonScript/Try_replace_function.py', wdir='C:/Users/cp1/PythonScript')
File "C:\Users\cp1\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\cp1\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/cp1/PythonScript/Try_replace_function.py", line 14, in <module>
similarity_M = numpy.empty((size_of_similarity_M,size_of_similarity_M))
MemoryError
How I can solve this in a easily way, without update all script? Of course for a small number in size_of_similarity_M
, it works well.
I wouldn't change the format of similarity_M
, since I use the output of this matrix in other script.
Upvotes: 1
Views: 372
Reputation: 10641
numpy.arrays are meant to live in memory. If you want to work with matrices larger than your RAM, you have to work around that. There are at least two approaches you can follow:
Upvotes: 1