-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_loss.py
52 lines (40 loc) · 1.15 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
42
43
44
45
46
47
48
49
50
51
52
import pickle
import numpy
import matplotlib.pyplot as plt
all_reconloss = []
all_ncut = []
with open('reconstruction_loss.pkl','rb') as f:
while True:
try:
all_reconloss.append(pickle.load(f))
except EOFError:
break
with open('n_cut_loss.pkl','rb') as fb:
while True:
try:
all_ncut.append(pickle.load(fb))
except EOFError:
break
recon = numpy.array(all_reconloss) # changing to array
recon = recon.reshape((-1,1)) #making a single column
div = int(recon.shape[0]/100) # getting the last iteration divisible by 100
recon = recon[:div*100]
recon = recon.reshape((-1,100)).mean(axis=1) # takin mean of 100 iterations
n_cut = numpy.array(all_ncut)
n_cut = n_cut.reshape((-1,1))
div = int(n_cut.shape[0]/100)
n_cut = n_cut[:div*100]
n_cut = n_cut .reshape((-1,100)).mean(axis=1)
plt.figure(1)
#plt.subplot(211)
plt.title("Reconstruction Loss")
plt.ylabel("Loss")
plt.xlabel("Per 100 Iteration (Batch Size 10)")
plt.plot(recon)
plt.figure(2)
#plt.subplot(212)
plt.title("N-Cut Loss")
plt.ylabel("Loss")
plt.xlabel("Per 100 Iteration (Batch Size 10)")
plt.plot(n_cut)
plt.show()