-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
33 lines (27 loc) · 794 Bytes
/
main.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
import numpy as np
import seaborn as sb
import random
import CHL
# MNIST dataset
layerSizes = (784,16,16,10)
print("Reading dataset")
with np.load('mnist.npz') as data:
trainingInputs = data['training_images']
trainingOutputs = data['training_labels']
trainingData = list(zip(trainingInputs, trainingOutputs))
testingData = trainingData[:10000]
trainingData = trainingData[10000:]
# Define and train network
net = CHL.CHLNeuralNetwork(layerSizes)
print("Training network...")
net.train(trainingData, testingData, 5, .1)
# Results
x = random.randint(0, 10000)
dataPoint = testingData[x]
after = net.predict(dataPoint[0])
img = np.reshape(dataPoint[0], (28,28))
sb.heatmap(img)
print("Actual Number:")
print(np.argmax(dataPoint[1]))
print("Network Prediction:")
print(np.argmax(after))