def testTucker(): s = 8 r = 5 re = 3 size = [s,s,s] rank = [r,r,r] rank_estimate = [re,re,re] L = createTestLaplacian(s) alpha = 0.01 while True: #X = alg.randomTensorOfNorm(size,rank,0) dat = benchmark.ThreeDNoseData() X = dat["X"] L = dat["L"] X = X / norm(X) print "start estimation for tensor size of", X.shape (G,As) = alg.HOOI(X,rank_estimate,L,alpha) print "finished" Result = alg.expand(G,As) #print "original \n", X #print "estimated \n",Result print "error \n", norm(X - Result) raw_input()
def testTucker(): size = [3, 3, 3] rank = [3, 3, 3] rank_estimate = [1, 1, 1] X = randomTensorOfNorm(size, rank) (G, As) = alg.HOOI(X, rank_estimate) print "finished" Result = alg.expand(G, As) print "original \n", X print "estimated \n", Result print "error \n", norm(X - Result)
def approximate(Xin): (G,As) = alg.HOOI(Xin,rank_estimate,alpha,L) Xs = alg.expand(G,As) return Xs