-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplot_loss.py
41 lines (34 loc) · 1.16 KB
/
plot_loss.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
import pickle
import matplotlib.pyplot as plt
import numpy as np
with open('losses_record.pkl', 'rb') as f:
losses = pickle.load(f)
losses_sort = sorted(losses.items(),key=lambda x:x[0])
x = [item[0] for item in losses_sort]
y = [item[1] for item in losses_sort]
y = np.asarray(y)
rpn_loc_loss = y[:,0]
rpn_cls_loss = y[:,1]
roi_loc_loss = y[:,2]
roi_cls_loss = y[:,3]
total_loss = y[:,4]
window_smooth = 5
sx = []
srpn_loc_loss = []
srpn_cls_loss = []
sroi_loc_loss = []
sroi_cls_loss = []
stotal_loss = []
for i in range(len(x)//window_smooth):
sx.append(x[i*window_smooth])
srpn_loc_loss.append(rpn_loc_loss[i*window_smooth:(i+1)*window_smooth].mean())
srpn_cls_loss.append(rpn_cls_loss[i * window_smooth:(i + 1) * window_smooth].mean())
sroi_loc_loss.append(roi_loc_loss[i * window_smooth:(i + 1) * window_smooth].mean())
sroi_cls_loss.append(roi_cls_loss[i * window_smooth:(i + 1) * window_smooth].mean())
stotal_loss.append(total_loss[i * window_smooth:(i + 1) * window_smooth].mean())
plt.plot(sx,srpn_loc_loss,'r')
plt.plot(sx,srpn_cls_loss,'g')
plt.plot(sx,sroi_loc_loss,'b')
plt.plot(sx,sroi_cls_loss,'k')
plt.plot(sx,stotal_loss)
plt.show()