-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_validation.py
More file actions
46 lines (35 loc) · 1.17 KB
/
plot_validation.py
File metadata and controls
46 lines (35 loc) · 1.17 KB
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
import matplotlib.pyplot as plt
import glob
import sys
import os
def main():
files_to_parse = get_files(sys.argv[1])
parser = Parser(files_to_parse, [], [])
parser.update_points()
plt.xlabel('Steps')
plt.ylabel('Loss')
plt.title("Refuse Model Version 2 Loss vs. Steps")
plt.plot(parser.steps, parser.loss)
plt.show()
def get_files(f):
files_to_parse = []
if os.path.isdir(f):
for file in os.listdir(f):
files_to_parse.append(os.path.join(f, file))
else:
files_to_parse.append(f)
return files_to_parse
class Parser:
def __init__(self, files_to_parse, steps=[], loss=[]):
self.files_to_parse = files_to_parse
self.steps = steps
self.loss = loss
def update_points(self):
for filename in self.files_to_parse:
with open(filename) as f:
for line in f.readlines():
if "Loss/total_loss = " in line:
self.loss.append(float(line.split("Loss/total_loss = ")[-1].split(", ")[0]))
self.steps.append(int(line.split("global_step = ")[-1].split(", ")[0]))
if __name__ == "__main__":
main()