#lnErr = 1e-5 lnErr = 1e-2 for i in range(max+1): err = 0.0; for ii in range(len(input)): err += bpn.trainEpoch(npA(input[ii]),npA(target[ii])) if i%2500 == 0: #if i%20 == 0: print "iteration {0}\tError : {1:0.6f}".format(i,err) #bpn.NN_cout("Train_"+str(i)) if err <= lnErr: print "Min error reached at {0}".format(i) break #bpn.setWeights() bpn.printWeights() plt.figure(figsize=(10,5)) # Draw real function x,y = samples['x'],samples['y'] plt.plot(x,y,color='b',lw=1) # Draw network approximated function for i in range(len(input)): y[i] = bpn.run(npA(input[i])) plt.plot(x,y,color='r',lw=3) plt.axis([0,1,0,1]) plt.show()
for ii in range(len(input)): err += bpn.trainEpoch(npA(input[ii]),npA(target[ii])) err += bpn.trainEpoch(npA(input2[ii]),npA(target2[ii])) if i%2500 == 0: #if i%20 == 0: print "iteration {0}\tError : {1:0.6f}".format(i,err) #bpn.NN_cout("Train_"+str(i)) if err <= lnErr: print "Min error reached at {0}".format(i) break #bpn.setWeights() bpn.printWeights() for i in range(len(input)): output = bpn.run(npA(input[i])) print "in :"+str(input[i])+", ou : "+str(output) for i in range(len(input2)): output = bpn.run(npA(input2[i])) print "in2 :"+str(input2[i])+", ou2 : "+str(output) #bins = bins(20,0,100) #P.hist(v1,bins,histtype='step') #P.hist(v1,bins,histtype='step') """ plt.figure(figsize=(10,5)) # Draw real function