-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
50 lines (45 loc) · 1004 Bytes
/
test.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
import sys
import math
import subprocess
import os
# import preprocess
ideal_path = open('data/finaloutput.txt')
file_arg = str(300000)+" "+str(1)
os.system(("./apf "+file_arg))
text = open('apf_out.txt',"r")
array = []
def lossfunction(epoch_array,num):
step_down = 10000
error = 0
count = 0
for line in ideal_path:
if(count==num):
lineSplit = line.split(" ")
break
count+=1
i = 0
ideal = 0
count = 1
#print(lineSplit)
for word in lineSplit:
count+=1
if word == '(' or word == ',' or word == ')' or word == ' ' or word == '':
continue
else:
if(count<=len(lineSplit)) and i < len(epoch_array):
ideal = epoch_array[i]
i+=1
#print(i)
#print(word)
error += (int(ideal) - int(word))*(int(ideal) - int(word))
return error/step_down
for line in text:
lineSplit=line.split(" ")
count = 1
# print(len(lineSplit))
for word in lineSplit:
count+=1
if(count<=len(lineSplit)):
# print(word)
array.append(int(word))
print(lossfunction(array,1))