numpy.linalg.svd报错memory error解决

U,Sigma,VT = la.svd(dataMat,False)

我是200000*93的矩阵分解,报错memory error,是由于U和VT过大

查看文档:

numpy.linalg. svd ( afull_matrices=Truecompute_uv=True ) [source]

Singular Value Decomposition.

When a is a 2D array, it is factorized as u @ np.diag(s) @ vh = (u * s) @ vh, where u and vh are 2D unitary arrays and s is a 1D array of a‘s singular values. When a is higher-dimensional, SVD is applied in stacked mode as explained below.

Parameters:

a : (..., M, N) array_like

A real or complex array with a.ndim >= 2.

full_matrices : bool, optional

If True (default), u and vh have the shapes (..., M, M) and (..., N, N), respectively. Otherwise, the shapes are(..., M, K) and (..., K, N), respectively, where K = min(M, N).

compute_uv : bool, optional

Whether or not to compute u and vh in addition to s. True by default.

Returns:

u : { (..., M, M), (..., M, K) } array

Unitary array(s). The first a.ndim - 2 dimensions have the same size as those of the input a. The size of the last two dimensions depends on the value of full_matrices. Only returned when compute_uv is True.

s : (..., K) array

Vector(s) with the singular values, within each vector sorted in descending order. The first a.ndim - 2 dimensions have the same size as those of the input a.

vh : { (..., N, N), (..., K, N) } array

Unitary array(s). The first a.ndim - 2 dimensions have the same size as those of the input a. The size of the last two dimensions depends on the value of full_matrices. Only returned when compute_uv is True.

Raises:

LinAlgError

If SVD computation does not converge.

U,VT默认返回完整矩阵,通过将参数full_matrices设置为False,U,VT的shape就变为(..., M, K) 和 (..., K, N)   ,不再报错



你可能感兴趣的:(数据挖掘,Python)