-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
42 lines (30 loc) · 824 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
34
35
36
37
38
39
40
41
42
import numpy as np
from nn import nn
def run():
# dataset
data = np.array([
[[1, 1, 1],
[1, 0, 1],
[1, 1, 1]],
[[0, 1, 0],
[0, 1, 0],
[0, 1, 0]],
[[1, 0, 1],
[1, 1, 1],
[0, 0, 1]],
[[1, 1, 1],
[0, 0, 1],
[0, 0, 1]]
])
normalization = 10
data_annotation_target = np.array([
0, 1, 4, 7
]) / normalization
network = nn(3 * 3, 9)
network.train(data, data_annotation_target, "./weights.json")
network.read_from_file("weights.json")
for i, _ in enumerate(data):
predict = round(network.predict(data[i]) * normalization)
print(f"predict: {predict}, result: {predict == data_annotation_target[i] * normalization}")
if __name__ == "__main__":
run()