-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualize_training_progress.py
102 lines (79 loc) · 2.99 KB
/
visualize_training_progress.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import matplotlib.pyplot as plt
import numpy as np
import argparse
import os.path
parser = argparse.ArgumentParser()
parser.add_argument('names', nargs='+')
args = parser.parse_args()
fig_idx = 0
for file_name in args.names:
name = os.path.splitext(file_name)[0]
if not os.path.isfile(file_name):
print(f"file {file_name} does not exist")
f = open(file_name, "r")
lines = f.readlines()
semseg_mious_eval = []
semseg_mious_train = []
normals_rmse_eval = []
normals_rmse_train = []
percentage_executed_layers = []
model_loss = []
efficiency_loss = []
lines = [line.split() for line in lines]
for i, line in enumerate(lines):
if len(line) > 0 and line[0] == "Semantic":
if lines[i-2][0] != "Training":
semseg_mious_eval.append(float(line[-1]))
else:
semseg_mious_train.append(float(line[-1]))
if len(line) > 0 and line[0] == "rmse":
if lines[i-27][0] != "Training":
normals_rmse_eval.append(float(line[-1]))
else:
normals_rmse_train.append(float(line[-1]))
if len(line) > 5 and line[5] == "%" and line[6] == "Activated":
percentage_executed_layers.append(float(line[-1][:-1]))
if len(line) > 6 and line[5] == "model" and line[6] == "loss":
model_loss.append(float(line[7]))
efficiency_loss.append(float(line[11]))
# visualize accuracy
assert len(semseg_mious_eval) == len(normals_rmse_eval) and len(
normals_rmse_eval) == len(percentage_executed_layers)
assert len(semseg_mious_train) == len(normals_rmse_train)
fig = plt.figure(fig_idx)
fig_idx += 1
ax = fig.add_subplot(111)
xs_eval = np.arange(len(semseg_mious_eval))
ax.plot(xs_eval, semseg_mious_eval,
c='forestgreen', label="semseg mIoU (eval)")
ax.plot(xs_eval, normals_rmse_eval, c='royalblue',
label="normals rmse (eval)")
xs_eval = np.arange(1, len(semseg_mious_eval))
ax.plot(xs_eval, semseg_mious_train,
c='lightgreen', label="semseg mIoU (train)")
ax.plot(xs_eval, normals_rmse_train, c='lightskyblue',
label="normals rmse (train)")
ax2 = ax.twinx()
xs_eval = np.arange(len(semseg_mious_eval))
plt.plot(xs_eval, percentage_executed_layers, c='red', label="% FLOPS")
ax2.set_ylabel(r"FLOPS (%)")
ax.legend(loc='upper center', bbox_to_anchor=(
0.5, 1.25), ncol=2, fontsize=10)
ax2.legend(loc=1)
plt.grid()
plt.title(name)
plt.tight_layout()
plt.savefig(f"{name}_accuracy.png")
fig = plt.figure(fig_idx)
fig_idx += 1
xs = np.arange(len(model_loss))
ax = fig.add_subplot(111)
ax.plot(xs, model_loss, c="r", label="model loss")
ax.legend(loc=1)
# Creating Twin axes for dataset_1
ax2 = ax.twinx()
ax2.plot(xs, efficiency_loss, c="b", label="efficiency loss")
ax2.legend(loc=2)
ax.grid()
plt.title(name)
plt.savefig(f"{name}_loss.png")