Esempio n. 1
0
def Evaluation_CP():
    """
    CP分解のクロスバリデーションによる評価
    """
    logger = Logger("CPEvaluation")
    s = 20
    r = 3
    re = 2
    size = [s, s, s]
    rank = r
    rank_estimate = re

    alpha = 0.001

    logger.WriteLine("TensorSize=" + str(size))
    logger.WriteLine("TensorRank=" + str(rank))
    logger.WriteLine("EstimationRank" + str(rank_estimate))

    Y = alg.randomTensorOfNorm(size, rank, 0.05) * 100
    I = alg.createUnitTensor(len(size), rank)
    while True:
        testrates = [0.1 * (i + 1) for i in xrange(9)]
        for zerorate in testrates:

            W = createMask(size, zerorate)

            def approximate(Xin):
                As = alg.RRMFCP(Xin, rank_estimate, alpha)
                Xs = alg.expand(I, As)
                return Xs

            X = comp.Completion(Y, W, approximate)
            diff = norm(Y - X)
            logger.WriteLine(str(zerorate) + " " + str(diff))
            print "rate:", zerorate, "error:", norm(Y - X)
Esempio n. 2
0
def Evaluation_Tucker():
    """
    Tucker分解のクロスバリデーションによる評価
    """
    logger = Logger("TuckerEvaluation")
    s = 20
    r = 3
    re = 2
    size = [s, s, s]
    rank = [r, r, r]
    rank_estimate = [re, re, re]

    logger.WriteLine("TensorSize=" + str(size))
    logger.WriteLine("TensorRank=" + str(rank))
    logger.WriteLine("EstimationRank" + str(rank_estimate))

    Y = alg.randomTensorOfNorm(size, rank, 0.05) * 100
    while True:
        testrates = [0.02 * (i + 1) for i in xrange(49)]
        for zerorate in testrates:

            W = createMask(size, zerorate)

            def approximate(Xin):
                (G, As) = alg.HOOI(Xin, rank_estimate)
                Xs = alg.expand(G, As)
                return Xs

            X = comp.Completion(Y, W, approximate)
            diff = norm(Y - X)
            logger.WriteLine(str(zerorate) + " " + str(diff))
            print "rate:", zerorate, "error:", norm(Y - X)
Esempio n. 3
0
def Evaluation_Tucker():
    """
    Tucker分解のクロスバリデーションによる評価
    """
    logger = Logger("TuckerEvaluation")
    s = 20
    r = 3
    re = 2 
    size = [s,s,s]
    rank = [r,r,r]
    rank_estimate = [re,re,re]

    logger.WriteLine("TensorSize="+str(size))
    logger.WriteLine("TensorRank="+str(rank))
    logger.WriteLine("EstimationRank"+str(rank_estimate))

    Y = alg.randomTensorOfNorm(size,rank,0.05) * 100 
    while True:
        testrates = [0.02 * (i+1) for i in xrange(49)]
        for zerorate in testrates:

            W = createMask(size,zerorate)

            def approximate(Xin):
                (G,As) = alg.HOOI(Xin,rank_estimate)
                Xs = alg.expand(G,As)
                return Xs

            X = comp.Completion(Y,W,approximate)
            diff = norm(Y-X)
            logger.WriteLine(str(zerorate)+ " " + str(diff))
            print "rate:", zerorate, "error:", norm(Y-X)
Esempio n. 4
0
def Evaluation_CP():
    """
    CP分解のクロスバリデーションによる評価
    """
    logger = Logger("CPEvaluation")
    s = 20
    r = 3
    re = 2 
    size = [s,s,s]
    rank = r 
    rank_estimate = re 

    alpha = 0.001

    logger.WriteLine("TensorSize="+str(size))
    logger.WriteLine("TensorRank="+str(rank))
    logger.WriteLine("EstimationRank"+str(rank_estimate))

    Y = alg.randomTensorOfNorm(size,rank,0.05) * 100 
    I = alg.createUnitTensor(len(size),rank)
    while True:
        testrates = [0.1 * (i+1) for i in xrange(9)]
        for zerorate in testrates:

            W = createMask(size,zerorate)

            def approximate(Xin):
                As = alg.RRMFCP(Xin,rank_estimate,alpha)
                Xs = alg.expand(I,As)
                return Xs

            X = comp.Completion(Y,W,approximate)
            diff = norm(Y-X)
            logger.WriteLine(str(zerorate)+ " " + str(diff))
            print "rate:", zerorate, "error:", norm(Y-X)
Esempio n. 5
0
 def getTensor(mat):
     size = 30
     rank = 20
     sl = [100,100,500]
     rl = [rank,rank,rank]
     return algorithm.randomTensorOfNorm(sl,rl,0.01)
Esempio n. 6
0
 def getTensor(mat):
     size = 30
     rank = 20
     sl = [100, 100, 500]
     rl = [rank, rank, rank]
     return algorithm.randomTensorOfNorm(sl, rl, 0.01)