#Normalise CV data from 0..255 to 0..1 X_CV = DATA_CV[:, 1:].T / 255.0 #Empty list to collect CV errors CV_error = [] #Let's iterate! for i in xrange(iterations): #Get miniBatch of defined size from whole DATA X = getBatch(DATA, batchSize, validDataIndexes) #Train on given data/labels AE.trainCalc(X, X, iteration=1, debug=True, errorCollect=True) #Check CV error every *checkCvEvery* cycles if i % checkCvEvery == 0: #Caclculate CV error give CV data/labels CV_error.append(NNsupport.crossV(X_CV, X_CV, AE)) #Print current CV error print 'CV error: ', CV_error[-1] #Draw how error and accuracy evolves vs iterations Graph.Builder(name='AE_error.png', error=AE.errorArray, cv=CV_error, legend_on=True) #Visualise hidden layers weights AE.weightsVisualizer(folder='.', size=(28, 28))
#Plot predicted decision boundary plot(x, y_predicted, 'g.', markeredgewidth=0, label='Predicted boundary') #Plot original decision boundary plot(x, y, 'r.', markeredgewidth=0, label='Original boundary') #Plot raw data plot(data[0, :], data[1, :], 'b,', label='data') #Draw legend legend(loc='upper right', fontsize=10, numpoints=3, shadow=True, fancybox=True) #Eanble grid grid() #Save plot to file savefig('data' + str(i) + '.png', dpi=120) #Close and clear current plot close() #Estimate Neural Network error (square error, "distance" between real and predicted value) on cross-validation cv_err.append(NNsupport.crossV(CV_labels, CV, NN)) #Estimate network's accuracy accuracy = np.mean(CV_labels == np.round(NN.out)) acc.append(accuracy) #Draw how error and accuracy evolves vs iterations Graph.Builder(name='NN_error.png', error=NN.errorArray, cv=cv_err, accuracy=acc, legend_on=True)
# Normalise CV data from 0..255 to 0..1 X_CV = DATA_CV[:, 1:].T / 255.0 # Empty list to collect CV errors CV_error = [] # Let's iterate! for i in xrange(iterations): # Get miniBatch of defined size from whole DATA X = getBatch(DATA, batchSize, validDataIndexes) # Train on given data/labels AE.trainCalc(X, X, iteration=1, debug=True, errorCollect=True) # Check CV error every *checkCvEvery* cycles if i % checkCvEvery == 0: # Caclculate CV error give CV data/labels CV_error.append(NNsupport.crossV(X_CV, X_CV, AE)) # Print current CV error print "CV error: ", CV_error[-1] # Draw how error and accuracy evolves vs iterations Graph.Builder(name="AE_error.png", error=AE.errorArray, cv=CV_error, legend_on=True) # Visualise hidden layers weights AE.weightsVisualizer(folder=".", size=(28, 28))