Exemple #1
0
'''
    Load the data. For this demo, we're using sklearn's digits dataset
    Digits are 8x8 pixel images. Each row is one image, in a linear format,
    where columns 65-74 correspond to one hot encoded responses representing
    digits 0 through 9. 1797 rows 74 columns
'''
data = np.loadtxt("transformed.csv", delimiter = ',')
m = len(data)

# Split the data into training set and test set.
train_set = data[:(3*m/4),:]
test_set = data[m/4:,:]

# Instantiate a new neural network. 64 input, 64 hidden, 10 output nodes.
NN = NeuralNetwork(64,HIDDEN_NODES,10,LEARNING_RATE,ITERATIONS)

# Train on the training set, test on the test set. The test() function
# will print out the percent correctness on the test set.
errors = NN.train(train_set)
NN.test(test_set)



# Plot the error curve
if VIEW_PLOT == True:
    plt.plot(errors)
    plt.title("Average Error Per Iteration On Training Set")
    plt.xlabel("Iteration")
    plt.ylabel("Average Error")
    pylab.show()