(800, 28)\
]
TIMES = 100
SHORTCARD = 256
SPEED = 0.01
DROP_INPUT = 0.2
DROP_HIDDEN = 0.6
PRINT_FROM = 10
PRINT_TO = 50
STEP_SHOW = 3
RHO = 0.9
EPSILON = 1e-4
STEP = 50
print "test"

trX, teX = load.loadMel("afterLDA100.db")
# trY, teY = load.loadRes()
trZ, teZ = load.loadLeter()
print "loaded"
neur = Neural()
# neur.load_from_file(WEIGHTS_FILE)
neur.init_model(ARR_SHAPE)
neur.train(trX, teX, trZ, teZ, epochs=TIMES)

neur.save_to_file(WEIGHTS_FILE)


# trT = neur.result(trX)
# teT = neur.result(teX)
# print "start train"
# neur2 = Neural()
import time
startt = time.time()
import numpy as np
import ujson
import load
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
print "test"

DIM = 100

mel = load.loadMel()[0]
res_class = load.loadClass()[0]
print "loaded"
# print res[0]
# def myfunc(a):
# 	print a
# 	return a.tolist().index(1)

def save_to_file(X, filename='afterLDA'):
	with open(filename + str(DIM) + ".db", 'w') as f:
		ujson.dump(X.tolist(), f)
		
# vfunc = np.vectorize(myfunc)
# res_class = vfunc(res)
clf = LinearDiscriminantAnalysis(n_components=DIM)
print "train"
clf.fit(mel, res_class)
print "trained"
print clf.predict(mel[:10])
pred = clf.predict(mel)
print res_class[:10]
Example #3
0
import time
startt = time.time()
import numpy as np
import ujson
import load
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
print "test"

DIM = 100

mel = load.loadMel()[0]
res_class = load.loadClass()[0]
print "loaded"
# print res[0]
# def myfunc(a):
# 	print a
# 	return a.tolist().index(1)


def save_to_file(X, filename='afterLDA'):
    with open(filename + str(DIM) + ".db", 'w') as f:
        ujson.dump(X.tolist(), f)


# vfunc = np.vectorize(myfunc)
# res_class = vfunc(res)
clf = LinearDiscriminantAnalysis(n_components=DIM)
print "train"
clf.fit(mel, res_class)
print "trained"
print clf.predict(mel[:10])