pythonsvd内存不足,numpy svd中的内存错误

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值