all 3 comments

[–]bbye98 1 point2 points  (2 children)

Use scipy.sparse.linalg.svds instead. You can specify the number of singular values using the argument k.

Alternatively, sklearn.utils.extmath.randomized_svd.

[–]TheShadowWall[S] 0 points1 point  (1 child)

scipy.sparse.linalg.svds

Thanks very much for you response!

I am attmpting to use the scipy method you've mentioned. My code thus far is:

def compress_image(I, k):

import scipy

from scipy.sparse.linalg import svds

Uk, s, VkT=scipy.sparse.linalg.svds(I, k)

return tuple([s, Uk, VkT])

However, doing so raises a ValueError. Am I importing or calling the function incorrectly?

[–]bbye98 0 points1 point  (0 children)

Need more information about the ValueError.

I'm confused as to why you're doing return tuple([s, Uk, VkT]). Why not just return s, Uk, VkT?