コード例 #1
0
ファイル: resgrouptrain.py プロジェクト: werg/gcpp
		accuracyfile = open(options.outfile + "/accuracy", 'w')
		levenfile = open(options.outfile + "/levenacc", 'w')
	

	
	if True:
		def csn():
			for c in charstream(refsource):
				if random.random() < LEVENMUTATE:
					yield random.choice(balph)
				else:
					yield c
					
		vcsn = vs(csn())
	else:
		vcsn = resnet.extremeRI(len(balph))
	
	if options.load:
		loadfile = open(options.load)
		(startgroup, group) = cPickle.load(loadfile)
		loadfile.close()
		if not options.store:
			options.store = options.load
		group._copyrepair()
		startgroup._copyrepair()

	else:
		group = resgroup.ResGroup(SIZE, NETSIZE, refdata, vcsn, INSIZE, len(balph), SPARSE, SCALE, PRETIMES)
			
		group._copyscrub()
		startgroup = copy.deepcopy(group)
コード例 #2
0
ファイル: resclasstrain.py プロジェクト: werg/gcpp
		yield np.mat([[1.0 if d == c else -1.0] for d in balph])

#balph = ['1', '0']	
#def vcs():
#	while True:
#		yield np.mat([[1.0],[-1.0]])

TIMES = 9000
RESSIZE = 600

# ressize, insize, sparseness, scale
classifier = resnet.ResClass(RESSIZE, len(balph), 0.3, 0.5)


		   
classifier.pretrain(vcs(), resnet.extremeRI(len(balph)), TIMES, 80)
	
teststring = [v for (v,_) in zip(vcs(), xrange(100))]
testout = ''
for out in classifier.run_signal(teststring):
	testout += '+' if out[0][0,0] > 0 else '-'
	
print ''.join([helpers.pick_letter(balph, t) for t in teststring])
print testout

	 
teststring = [v for (v,_) in zip(resnet.extremeRI(len(balph)), xrange(100))]
testout = ''
for out in classifier.run_signal(teststring):
	testout += '+' if out[0][0,0] > 0 else '-'