-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplotter.py
61 lines (52 loc) · 1.72 KB
/
plotter.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 14 21:00:54 2018
@author: Marcel Himmelreich
"""
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from keras.callbacks import History
history = History()
class Plotter():
def __init__(self, history, filename):
self._history = history
self._filename = filename
def plotAccuracy(self, filepath, val = False):
try:
plt.plot(self._history['acc'])
if val:
plt.plot(self._history['val_acc'])
plt.legend(['train', 'test'], loc='upper left')
plt.title('Model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
filename = filepath + "model_accuracy_"+self._filename
plt.savefig(filename + ".png")
plt.show()
plt.clf()
except Exception as e:
print("Failed to plot accuracy/epoch plot")
print(e)
def plotLoss(self, filepath, val = False):
try:
plt.plot(self._history['loss'])
if val:
plt.plot(self._history['val_loss'])
plt.legend(['train', 'test'], loc='upper left')
plt.title('Model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
filename = filepath + "model_loss_"+self._filename
plt.savefig(filename + ".png")
plt.show()
plt.clf()
except Exception as e:
print("Failed to plot accuracy/epoch plot")
print(e)
def plotAccLoss(self, filepath, val = False):
try:
print()
except Exception as n:
print()