def train(): input, target = get_train_data() input = reshape(input, (-1, 42)) / 10 er = len(input) while er > len(input) / 20: er = 0 net = nl.net.newff(nl.tool.minmax(input), [12, 4], transf=[nl.trans.TanSig(), nl.trans.LogSig()]) net.trainf = nl.train.train_bfgs error = net.train(input, target, epochs=1000, show=10, goal=0.01) output = net.sim(input) out = [[0 for i in range(4)] for j in range(len(output))] for i in range(len(output)): m = max(output[i]) for j in range(4): if output[i, j] == m: out[i][j] = 1 if out[i] != target[i]: er += 1 print 'Error :', er print len(target), er #chdir('/home/sarath/MY_PRojects/gesture') print "directory changed to gesture" cPickle.dump(net, open('net.net', 'w'))
def test(): input,target=get_train_data(); input=reshape(input,(-1,42))/10 chdir('/home/sarath/My_PRojects/gesture') net=cPickle.load(open('net.net','r')) output = net.sim(input) #after gettig the simulated data checking how well it works err=0 out=[[0 for i in range(4)] for j in range(len(output))] for i in range(len(output)): m=max(output[i]) for j in range(4): if output[i,j] == m: out[i][j] =1 if out[i] != target[i]: err+=1; print "The Error is :",float(err)/len(input)*100," %"
def test(): input, target = get_train_data() input = reshape(input, (-1, 42)) / 10 chdir('/home/sarath/My_PRojects/gesture') net = cPickle.load(open('net.net', 'r')) output = net.sim(input) #after gettig the simulated data checking how well it works err = 0 out = [[0 for i in range(4)] for j in range(len(output))] for i in range(len(output)): m = max(output[i]) for j in range(4): if output[i, j] == m: out[i][j] = 1 if out[i] != target[i]: err += 1 print "The Error is :", float(err) / len(input) * 100, " %"
def train(): input,target=get_train_data(); input=reshape(input,(-1,42))/10 er=len(input) while er > len(input)/20: er=0; net = nl.net.newff(nl.tool.minmax(input), [12, 4], transf = [nl.trans.TanSig(), nl.trans.LogSig()]) net.trainf = nl.train.train_bfgs error = net.train(input, target, epochs=1000, show=10, goal=0.01) output = net.sim(input) out=[[0 for i in range(4)] for j in range(len(output))] for i in range(len(output)): m=max(output[i]) for j in range(4): if output[i,j] == m: out[i][j] =1 if out[i] != target[i]: er+=1 print 'Error :',er print len(target),er #chdir('/home/sarath/MY_PRojects/gesture') print "directory changed to gesture" cPickle.dump(net,open('net.net','w'))