-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevaluation_tools.py
42 lines (35 loc) · 1.08 KB
/
evaluation_tools.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
import matplotlib.pyplot as plt
import logs_centre
logger = logs_centre.get_logger(__name__)
def plot_acc_wrt_epochs(history):
fig = plt.figure()
plt.plot(history.history['acc'])
plt.plot(history.history['val_acc'])
plt.title('Model accuracy')
plt.ylabel('Accuracy')
plt.xlabel('Epoch')
plt.legend(['Train', 'Test'], loc='upper left')
plt.show()
save_plot(fig)
plt.clf()
def plot_loss_wrt_epochs(history):
fig = plt.figure()
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('Model loss')
plt.ylabel('Loss')
plt.xlabel('Epoch')
plt.legend(['Train', 'Test'], loc='upper left')
plt.show()
save_plot(fig)
plt.clf()
def save_plot(fig):
while True:
response = input('Do you want to save the current plot? (y/n)')
if response == 'n':
break
elif response == 'y':
title = input('Please enter the filename:')
fig.savefig(title + '.png')
logger.info('Saved current plot to {}'.format(title + '.png'))
break