-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlog_reader.py
51 lines (48 loc) · 1.02 KB
/
log_reader.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
import sys
import matplotlib.pyplot as plt
files = sys.argv[1:]
def is_number(n):
try:
float(n)
except ValueError:
return False
return True
# epoch = 1
vals = []
episode = []
last_episode = -1
for file in files:
f = open(file, "r")
lines = f.readlines()
for line in lines:
# if last_episode > 6000:
# break
words = line.split()
numbers = []
for word in words:
if(word.isnumeric()):
numbers.append(word)
if(int(numbers[0]) > 25000):
break
episode.append(int(numbers[0]))
vals.append(int(numbers[2]))
# ep = int(words[0])
# if is_number(ep):# and epoch%5 == 0:
# if ep > last_episode:
# episode.append(ep)
# last_episode = ep
# else:
# continue
# if is_number(words[-1]):# and epoch%5 == 0:
# vals.append(int(words[-1]))
# if(int(words[0]) > 5000):
# break
# print("YES")
# epoch += 1
# plt.plot(vals)
print(len(episode), len(vals))
# plt.ylim(top=900)
plt.plot(episode,vals)
plt.xlabel("Episodes")
plt.ylabel("Average Rewards")
plt.show()