C1W4Ex5, Eigenvector scaling

Hello! In program assignment, exercise 5 for week 4 why we don’t scale eigenvectors by their norms?

There is no mathematical requirement to do that, but a lot of the library functions that compute eigenvectors do return them with norm = 1. You can check that is what is happening here. So we don’t need to do anything: the function scipy.sparse.linalg.eigsh takes care of it for us.

Got it, I had to look up in the documentation, thanks :slight_smile:

I also checked the docs for np.linalg.eig and np.linalg.eigh and they also return unit vectors. I also verified it with this code:

# paul addition: check that the eigenvectors are returned with norm = 1
thenorms = np.linalg.norm(eigenvecs, axis = 0, keepdims = True)
print(f"eigenvecs.shape {eigenvecs.shape}")
print(f"thenorms.shape {thenorms.shape}")
print(f"norms of eigenvecs {thenorms}")

Running that gives this result:

eigenvecs.shape (4096, 55)
thenorms.shape (1, 55)
norms of eigenvecs [[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.
  1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.
  1. 1. 1. 1. 1. 1. 1.]]
1 Like