Search code examples
pythonarraysnumpydimensionssvd

Calculate dimensions of NumPy SVD matrices


I've calculated the Singular Value Decomposition (SVD) matrices with NumPy, upon a (22000,400) array, by the command

u, s, vh = np.linalg.svd(final_array, full_matrices=False)

I've printed u, s and vh, and it's working fine. Now I'm trying to visualize their dimensions, using:

u.shape()
s.shape()
vh.shape()

But I keep getting the error:

TypeError: 'tuple' object is not callable

How could I solve this issue?


Solution

  • In Numpy, shape is a property (which stores a tuple), not a method. Try u.shape.

    import numpy as np
    a = np.array([1,2])
    a.shape # (2,)