-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_plot.py
60 lines (40 loc) · 1.21 KB
/
main_plot.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import numpy as np
from utils import *
from neural_plot import *
import math
import sys
import csv
max_iterations = 1000
epsilon = 0.0000010000
def main():
np.set_printoptions(precision=5)
network = []
fnetwork = open(sys.argv[1], "r")
regularization = float(fnetwork.readline())
alpha = float(fnetwork.readline())
for line in fnetwork:
network.append(int(line))
fnetwork.close()
inputs = []
predictions = []
fdataset = open(sys.argv[2], "r")
i = 0
for l in fdataset:
a, b = l.split(";")
inputs.append([])
for v in a.split(","):
inputs[i].append(float(v))
predictions.append([])
for v in b.split(","):
predictions[i].append(float(v))
i = i + 1
for l in range(0, len(inputs)):
inputs[l] = np.array(inputs[l], ndmin=2).T
for l in range(0, len(predictions)):
predictions[l] = np.array(predictions[l], ndmin=2).T
fdataset.close()
weights=build_weights(network)
inputs = normalize(np.asarray(inputs))
neural_network(network, weights, regularization, inputs, predictions, max_iterations,alpha, sys.argv[3])
if __name__ == "__main__":
main()