-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (23 loc) · 844 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
import perceptron as ai
import random
def train():
# META PARAMETERS
layers = [64, 32, 10]
ratio = 0.1
batch_size = 10
epochs = 50
per = ai.Perceptron(layers, ratio)
dataset = ai.load_dataset('dataset.csv', ";", False, True)
for epoch in range(epochs):
random.shuffle(dataset) # Better results when dataset is shuffled
per.train(dataset, batch_size)
acc, error = per.get_stats(dataset)
print("[ EPOCH: %d || Accuracy: %.3f %% || Error: %.3f ]" % (epoch+1, acc * 100, error))
per.save("digitReader")
def test():
per = ai.Perceptron.load("digitReader")
dataset = ai.load_dataset('dataset.csv', ";", False, True)
acc, error = per.get_stats(dataset)
print("[ Accuracy: %.3f %% || Error: %.3f ]" % (acc * 100, error))
if __name__ == '__main__':
test()