forked from ucsd-hep-ex/L1METML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
epoch_all.py
68 lines (43 loc) · 1.2 KB
/
epoch_all.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
61
62
63
64
65
66
67
68
import numpy as np
import matplotlib.pyplot as plt
import math
loss_file = open("loss_data.log", 'r')
table = loss_file.readline()
table_split = table.split(",")
print("###############\n")
print("Select variable\n")
for i, var in enumerate(table_split):
print("{}\t {}".format(i, var))
if '\n' in var:
table_split[i] = table_split[i].replace('\n', '')
num_var = int(input("Input number 0 ~ 10 : "))
print("\n###############\n")
print("Plot {} vs epoch curve".format(table_split[num_var]))
epoch_ = 0
plot_maxi = 0
array_epoch = []
array_var = []
while True:
line = loss_file.readline()
if not line:
break
line_split = line.split(",")
temp_var = line_split[num_var]
array_epoch.append(epoch_)
array_var.append(temp_var)
if plot_maxi < float(temp_var):
plot_maxi = float(temp_var)
epoch_ += 1
array_var = list(map(float, array_var))
plot_maxi = plot_maxi * 1.1
plt.plot(array_epoch, array_var)
plt.title(table_split[num_var])
plt.xlabel("epoch")
plt.ylabel(table_split[num_var])
# plt.ylim(0,5000)
# plt.ylim(0,plot_maxi)
# plt.xlim(0,140)
plt.grid()
plt.show()
plt.savefig("loss_plot/{}.png".format(table_split[num_var]))
loss_file.close()