[2af92b]: / brainDecode / towardMoabbIntegration / utils / TrainingViewer.py

Download this file

122 lines (88 with data), 2.8 kB

  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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# TODO, get this to work:
print(max(accuracy_rec[:,1]))
def smoothing(record, smoothingRadius):
if record.shape[0] > 2 * smoothingRadius :
record_smooth = np.zeros((record.shape[0] - (2 * smoothingRadius), record.shape[1]))
for i in range(record_smooth.shape[0]):
for j in range(record_smooth.shape[1]):
record_smooth[i,j] = record[i:i+2*smoothingRadius,j].mean()
return record_smooth
# Define smoothing radius here
smoothingRadius = 10
population_loss_rec = loss_rec
population_accuracy_rec = accuracy_rec
population_loss_smooth = smoothing(loss_rec, smoothingRadius)
population_accuracy_smooth = smoothing(accuracy_rec, smoothingRadius)
individual_loss_rec = loss_rec
individual_accuracy_rec = accuracy_rec
individual_loss_smooth = smoothing(loss_rec, smoothingRadius)
individual_accuracy_smooth = smoothing(accuracy_rec, smoothingRadius)
import matplotlib.pyplot as plt
plt.figure(figsize=(12,8))
plt.title('First training Training')
plt.subplot(221)
handles = plt.plot(population_loss_rec)
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(222)
handles = plt.plot(population_loss_smooth)
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(223)
handles = plt.plot(population_accuracy_rec)
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(224)
handles = plt.plot(population_accuracy_smooth)
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.show()
plt.figure(figsize=(12,8))
plt.title('Classifier re-training Training')
plt.subplot(221)
handles = plt.plot(individual_loss_rec)
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(222)
handles = plt.plot(individual_loss_smooth)
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(223)
handles = plt.plot(individual_accuracy_rec)
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(224)
handles = plt.plot(individual_accuracy_smooth)
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.show()
plt.figure(figsize=(12,8))
plt.subplot(221)
handles = plt.plot(population_loss_rec)
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(222)
handles = plt.plot(population_loss_smooth)
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(223)
handles = plt.plot(population_accuracy_rec)
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.subplot(224)
handles = plt.plot(population_accuracy_smooth)
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(handles, ['train', 'test'])
plt.show()