I am performing numpy svd
U, S, V = np.linalg.svd(A)
shape of A is :
(10000, 10000)
Due to the large size, it gives me memory error :
U, S, V = np.linalg.svd(A, full_matrices=False) # nargout=3
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 1319, in svd
work = zeros((lwork,), t)
MemoryError
Then how can I find svd for my matrix?
解决方案
Some small tips:
Close everything else that is open on your computer. Remove all unnecessary memory hogging things in your program by setting the variables you don't need anymore to None. Say you used a big dict D for some computations earlier but don't need it anymore set D = None. Try initializing your numpy arrays with dtype=np.int32 or dtype=np.float32 to lower memory requirements.
Depending on what you need the SVD for you can also have a look at the scikit-learn package for python, they have support for many decomposition methods such as PCA and SVD together with sparse matrix support.