Skip to content

Instantly share code, notes, and snippets.

@KhyatiMahendru
Created July 23, 2019 05:55
Show Gist options
  • Save KhyatiMahendru/796099ca1361d681fff1576aa2b07fa3 to your computer and use it in GitHub Desktop.
Save KhyatiMahendru/796099ca1361d681fff1576aa2b07fa3 to your computer and use it in GitHub Desktop.
import numpy as np
from sklearn.utils.extmath import randomized_svd
A = np.array([[-1, 2, 0], [2, 0, -2], [0, -2, 1]])
u, s, vt = randomized_svd(A, n_components = 2)
print("Left Singular Vectors:")
print(u)
print("Singular Values:")
print(np.diag(s))
print("Right Singular Vectors:")
print(vt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment