예제 #1
0
MSize = args.MS
gamma = args.gamma
AFill = args.fill
startSeed = args.seed

###  Generate the solution for comparison purposes ###
print "Generating simulation data with known decomposition"
TM, TMHat = simultTools.generateSolution(MSize, R, AFill, alpha)
TMFull = TM.toTensor() + TMHat.toTensor()
np.random.seed(startSeed)

outfile = open('results/iteration-{0}.json'.format(exptID), 'w')

for sample in range(10):
    ## generate a random problem
    X = simultTools.generateRandomProblem(TMFull)  #sparse tensor
    data = {
        'exptID': exptID,
        'size': MSize,
        'sparsity': AFill,
        'sample': sample,
        "rank": R,
        "alpha": alpha,
        "gamma": gamma,
        "seed": startSeed
    }
    seed = sample * 1000
    for innerIt in [1, 2, 5, 10]:
        ## set seed for consistency
        np.random.seed(seed)
        ## solve the solution
예제 #2
0
R = 3
alpha = 1
MSize = [2,2,2]
gamma = None
AFill = [2,2,2]
startSeed = 1

print "Generating simulation data with known decomposition"
TM, TMHat = simultTools.generateSolution(MSize, R, AFill, alpha)
TMFull = TM.toTensor() + TMHat.toTensor()
np.random.seed(startSeed)



#generate random problem
sample = 0
X = simultTools.generateRandomProblem(TMFull)
data = {'exptID': exptID, 'size': MSize, 'sparsity': AFill, 'sample': sample,
		"rank": R, "alpha": alpha, "gamma": gamma, "seed": startSeed}
## solve the solution
innerIt = 1
startTime = time.time()
spntf = SP_NTF.SP_NTF(X, R=R, alpha=alpha, maxinner = innerIt)
Yinfo = spntf.computeDecomp(gamma=gamma)
totalTime = time.time() - startTime
sampleResult = {
	"compTime": totalTime,
	"iterInfo": Yinfo,
	"fms": TM.greedy_fms(spntf.M[SP_NTF.REG_LOCATION])
	}
data[str(innerIt)] = sampleResult
예제 #3
0
exptID = args.expt
R = args.r
alpha = args.alpha
MSize = args.MS
gamma = args.gamma
AFill = args.fill
INNER_ITER = 5
MAX_ITER = 500

print "Generating simulation data with known decomposition"
## generate the solution
TM, TMHat = simultTools.generateSolution(MSize, R, AFill, alpha)
TMFull = TM.toTensor() + TMHat.toTensor()
## generate an observation from the known solution
X = simultTools.generateRandomProblem(TMFull)

data = {
    'exptID': exptID,
    'size': MSize,
    'sparsity': AFill,
    "rank": R,
    "alpha": alpha,
    "gamma": gamma
}


def calculateValues(TM, M):
    fms = TM.greedy_fms(M)
    fos = TM.greedy_fos(M)
    nnz = tensorTools.countTensorNNZ(M)
예제 #4
0
MSize = args.MS
gamma = args.gamma
AFill = args.fill
startSeed = args.seed

###  Generate the solution for comparison purposes ###
print "Generating simulation data with known decomposition"
TM, TMHat = simultTools.generateSolution(MSize, R, AFill, alpha)
TMFull = TM.toTensor() + TMHat.toTensor()
np.random.seed(startSeed)

outfile = open('results/iteration-{0}.json'.format(exptID), 'w')

for sample in range(10):
	## generate a random problem
	X = simultTools.generateRandomProblem(TMFull) #sparse tensor
	data = {'exptID': exptID, 'size': MSize, 'sparsity': AFill, 'sample': sample,
		"rank": R, "alpha": alpha, "gamma": gamma, "seed": startSeed}
	seed = sample*1000
	for innerIt in [1, 2, 5, 10]:
		## set seed for consistency
		np.random.seed(seed)
		## solve the solution
		startTime = time.time()
		spntf = SP_NTF.SP_NTF(X, R=R, alpha=alpha, maxinner = innerIt)
		Yinfo = spntf.computeDecomp(gamma=gamma)
		totalTime = time.time() - startTime
		sampleResult = {
			"compTime": totalTime,
			"iterInfo": Yinfo,
			"fms": TM.greedy_fms(spntf.M[SP_NTF.REG_LOCATION])