from DBN import DBN from dbn_util import * d, l = loadDataSet("train.txt", 784) #d=d[0:100] #l=l[0:100] testd, testl = loadDataSet("test.txt", 784) #testd=testd[0:10] #testl=testl[0:10] testD = DBN([100, 100]) testD.trainDBN(d, l, batchsize=[200, 20], numepoch=[50, 200]) testD.Print() r = [] for i in range(0, len(testd)): r.append(testD.predict(testd[i])) print testl c = map(lambda x: x + 1, map(argmax, r)) print c dif = array(c) - array(testl) print dif rate = 0.0 for i in range(0, len(testd)): if dif[i] == 0: rate += 1 print rate / len(testd)
from DBN import DBN from dbn_util import * import pickle import sys train_file = sys.argv[1] model_file = sys.argv[2] d, l = loadDataSet(train_file, 784) d = d[0:100] l = l[0:100] #testd=testd[0:10] #testl=testl[0:10] model = DBN([20, 10]) model.trainDBN(d, l, batchsize=[20, 10], numepoch=[10, 20]) file = open(model_file, "wb") pickle.dump(model, file) model.Print() file.close()
from DBN import DBN from dbn_util import * d, l = loadDataSet("train.txt", 784) # d=d[0:100] # l=l[0:100] testd, testl = loadDataSet("test.txt", 784) # testd=testd[0:10] # testl=testl[0:10] testD = DBN([100, 100]) testD.trainDBN(d, l, batchsize=[200, 20], numepoch=[50, 200]) testD.Print() r = [] for i in range(0, len(testd)): r.append(testD.predict(testd[i])) print testl c = map(lambda x: x + 1, map(argmax, r)) print c dif = array(c) - array(testl) print dif rate = 0.0 for i in range(0, len(testd)): if dif[i] == 0: rate += 1 print rate / len(testd)
from DBN import DBN from dbn_util import * import pickle import sys train_file = sys.argv[1] model_file = sys.argv[2] d,l=loadDataSet(train_file,784) d=d[0:100] l=l[0:100] #testd=testd[0:10] #testl=testl[0:10] model = DBN([20,10]) model.trainDBN(d,l,batchsize=[20,10],numepoch=[10,20]) file = open(model_file,"wb") pickle.dump(model,file) model.Print() file.close()