def __init__(self): numpy.random.seed(21) #Create a low rank matrix # n = 100000 # m = 100000 # self.r = 50 # nKnown = 10**4 # netflix-like # n = 480000 # m = 18000 # self.r = 200 # nKnown = 10**8 # close from netflix n = 480000 m = 18000 self.r = 200 nKnown = 10**6 # focusing on scalar-product n = 480000 m = 18000 self.r = 50 nKnown = 10**5 self.X = SparseUtils.generateSparseLowRank((n, m), self.r, nKnown) print(self.X.nnz)
def __init__(self): numpy.random.seed(21) #Create a low rank matrix n = 100000 m = 100000 self.r = 200 k = 10**6 self.X = SparseUtils.generateSparseLowRank((n, m), self.r, k)
def __init__(self): numpy.random.seed(21) #Create a low rank matrix n = 500000 m = 500000 self.r = 200 k = 10**6 print("Generating low rank") self.X = SparseUtils.generateSparseLowRank((n, m), self.r, k) print("Generating csarray") self.X = csarray.fromScipySparse(self.X, storageType="rowMajor") print("Done")
#Test if we can easily get the SVD of a set of matrices with low rank but under #a fixed structure import numpy import scipy.sparse from exp.util.SparseUtils import SparseUtils numpy.set_printoptions(suppress=True, precision=3, linewidth=150) shape = (15, 20) r = 10 k = 50 X, U, s, V = SparseUtils.generateSparseLowRank(shape, r, k, verbose=True) X = numpy.array(X.todense()) Y = numpy.zeros(X.shape) Y[X.nonzero()] = 1 print(Y) U2, s2, V2 = numpy.linalg.svd(Y) print(s2) X2 = numpy.zeros(X.shape) for i in range(r): X2 += s[i]*numpy.diag(U[:,i]).dot(Y).dot(numpy.diag(V[:, i]))