-
Notifications
You must be signed in to change notification settings - Fork 0
/
testNeuralNetDigits.py
40 lines (30 loc) · 912 Bytes
/
testNeuralNetDigits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
======================================================
Test the neural network model
======================================================
Author: Matt Schulman, 2015
"""
print(__doc__)
import numpy as np
from numpy import loadtxt
from sklearn import datasets
from sklearn.metrics import accuracy_score
from nn import NeuralNet
# learning rate parameters to be trained by hand
numEpochs = 100
learningRate = 0.3
epsilon = 0.12
regularization_parameter = 0.001
nodes_in_hidden_layers = [25]
# load the data
filenameX = 'data/digitsX.dat'
dataX = loadtxt(filenameX, delimiter=',')
filenameY = 'data/digitsY.dat'
dataY = loadtxt(filenameY, delimiter=',')
n,d = dataX.shape
# create NeuralNet class
modelNN = NeuralNet(nodes_in_hidden_layers, epsilon, learningRate, numEpochs)
# train neural network on digits data
modelNN.fit(dataX, dataY)
# find the training accuracy
# report the training accuracy