-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
98 lines (90 loc) · 2.07 KB
/
plot.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
import numpy as np
from matplotlib import pyplot as plt
from scipy.interpolate import make_interp_spline
files=open("vgg_log64.txt",'r')
files_byol=open("byol_log64.txt",'r')
mlp_files=open("mlp_log64.txt",'r')
byol_mlp_files=open("byol_mlp_log64.txt",'r')
vgg=[]
i=0
log=0.0
for f in files.readlines()[1:]:
f=f.strip('\n').split(',')
if len(f)>4:
continue
if i==100:
log/=100.
vgg.append(log)
log=float(f[1])
i=0
else:
i+=1
log+=float(f[1])
vgg=np.array(vgg)
print(vgg)
x=np.arange(vgg.shape[0])
######=====================
byol=[]
i=0
log=0.0
for f in files_byol.readlines()[1:]:
f=f.strip('\n').split(',')
if len(f)>4:
continue
if i==100:
log/=100.
byol.append(log)
log=float(f[1])
i=0
else:
i+=1
log+=float(f[1])
files_byol.close()
byol=np.array(byol)
##+++++++++++++++++++++++++++++
mlp=[]
i=0
log=0.0
for f in mlp_files.readlines()[1:]:
f=f.strip('\n').split(',')
if len(f)>4:
continue
if i==100:
log/=100.
mlp.append(log)
log=float(f[1])
i=0
else:
i+=1
log+=float(f[1])
mlp_files.close()
mlp=np.array(mlp)
##+++++++++++++++++++++++++++++
byol_mlp=[]
i=0
log=0.0
for f in byol_mlp_files.readlines()[1:]:
f=f.strip('\n').split(',')
if len(f)>4:
continue
if i==100:
log/=100.
byol_mlp.append(log)
log=float(f[1])
i=0
else:
i+=1
log+=float(f[1])
byol_mlp_files.close()
byol_mlp=np.array(byol_mlp)
print(byol.shape,vgg.shape)
#x_smooth = np.linspace(vgg.min(), vgg.max(), 300)
#y_smooth = make_interp_spline(vgg, x)(x_smooth)
plt.plot(x, vgg,color='#0000FF',label='standard vgg')
plt.plot(x, byol,color='#FF000F',label='byol')
plt.plot(x, mlp,color='#00FF00',label='MLP for standard vgg')
plt.plot(x, byol_mlp,color='#000F0F',label='byol with mlp')
plt.xlabel('iterations')
plt.ylabel('per-iter loss')
plt.legend()
plt.show()