-
Notifications
You must be signed in to change notification settings - Fork 4
/
plot_process.py
52 lines (43 loc) · 1.98 KB
/
plot_process.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
from setting import *
import matplotlib.pyplot as plt
def plotting():
plt.figure(1)
plt.plot(records['iterations'], records['err_train'], label='error per hundred iterations')
min_index = int(np.argmin(records['err_train']))
mini = records['err_train'][min_index]
plt.plot(min_index * 100, mini, color=color1, marker='o',
markersize=5, label='error minimum: ' + str(np.round(mini, 5)))
plt.title(choice.upper() + ' Train Error', fontsize=font2)
plt.legend(loc='upper right')
plt.xlabel('Number of iterations', fontsize=font3)
plt.ylabel('Error value', fontsize=font3)
plt.tight_layout()
plt.savefig('./figures/process/' + str(choice) + '_train.png')
# plt.show()
plt.close()
plt.figure(2)
plt.plot(records['iterations'], records['err_test'], label='error per hundred iterations')
min_index = int(np.argmin(records['err_test']))
mini = records['err_test'][min_index]
plt.plot(min_index * 100, mini, color=color1, marker='o',
markersize=5, label='error minimum: ' + str(np.round(mini, 5)))
plt.title(choice.upper() + ' Test Error', fontsize=font2)
plt.legend(loc='upper right')
plt.xlabel('Number of iterations', fontsize=font3)
plt.ylabel('Error value', fontsize=font3)
plt.tight_layout()
plt.savefig('./figures/process/' + str(choice) + '_test.png')
# plt.show()
plt.close()
# np.savetxt('./ann.csv', records['err_test'], delimiter=',')
print('time:{}'.format(start))
print('iteration:{}'.format(records['iterations'][-1]))
print('err_train:{}, err_test:{}'.format(records['err_train'], records['err_test']))
# print('loss_train:{}, loss_test:{}'.format(records['loss_train'], records['loss_test']))
print(min_index * 100)
if __name__ == '__main__':
choice = 'pdn'
checkpoint = torch.load('check_' + choice + '.pth')
start = checkpoint['time']
records = checkpoint['records']
plotting()