-
Notifications
You must be signed in to change notification settings - Fork 2
/
Plot_History_Result.py
89 lines (63 loc) · 4.42 KB
/
Plot_History_Result.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
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
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import argparse
import os
def plot_loss_curve(DeepConvNet_ELU,DeepConvNet_ReLU,DeepConvNet_LeakyReLU,EEGNet_ELU,EEGNet_ReLU,EEGNet_LeakyReLU):
plt.plot(DeepConvNet_ELU['loss'], '-b', label='DeepConvNet_ELU')
plt.plot(DeepConvNet_ReLU['loss'], '-g', label='DeepConvNet_ReLU')
plt.plot(DeepConvNet_LeakyReLU['loss'], '-r', label='DeepConvNet_LeakyReLU')
plt.plot(EEGNet_ELU['loss'], '-c', label='EEGNet_ELU')
plt.plot(EEGNet_ReLU['loss'], '-m', label='EEGNet_ReLU')
plt.plot(EEGNet_LeakyReLU['loss'], '-y', label='EEGNet_LeakyReLU')
plt.xlabel("Epoch",fontsize=13)
plt.legend(loc='best')
plt.ylabel("Loss Value",fontsize=13)
plt.title("(Loss Curve)Activation function comparision(All)",fontsize=18)
plt.show()
return "loss圖繪製成功"
def plot_EEGNet_accuracy_curve(DeepConvNet_ELU,DeepConvNet_ReLU,DeepConvNet_LeakyReLU,EEGNet_ELU,EEGNet_ReLU,EEGNet_LeakyReLU):
plt.plot(np.array(EEGNet_ELU['train_accuracy_history'])*100, '-b', label='ELU_train')
plt.plot(np.array(EEGNet_ReLU['train_accuracy_history'])*100, '-g', label='ReLU_train')
plt.plot(np.array(EEGNet_LeakyReLU['train_accuracy_history'])*100, '-r', label='LeakyReLU_train')
plt.plot(np.array(EEGNet_ELU['test_accuracy_history'])*100, '-c', label='ELU_test')
plt.plot(np.array(EEGNet_ReLU['test_accuracy_history'])*100, '-m', label='ReLU_test')
plt.plot(np.array(EEGNet_LeakyReLU['test_accuracy_history'])*100, '-y', label='LeakyReLU_test')
plt.xlabel("Epoch",fontsize=13)
plt.legend(loc='best')
plt.ylabel("Accuracy(%)",fontsize=13)
plt.title("Activation function comparision(EGGNet)",fontsize=18)
plt.show()
return "EEGNet Accuracy圖繪製成功"
def plot_DeepConvNet_accuracy_curve(DeepConvNet_ELU,DeepConvNet_ReLU,DeepConvNet_LeakyReLU,EEGNet_ELU,EEGNet_ReLU,EEGNet_LeakyReLU):
plt.plot(np.array(DeepConvNet_ELU['train_accuracy_history'])*100, '-b', label='ELU_train')
plt.plot(np.array(DeepConvNet_ReLU['train_accuracy_history'])*100, '-g', label='ReLU_train')
plt.plot(np.array(DeepConvNet_LeakyReLU['train_accuracy_history'])*100, '-r', label='LeakyReLU_train')
plt.plot(np.array(DeepConvNet_ELU['test_accuracy_history'])*100, '-c', label='ELU_test')
plt.plot(np.array(DeepConvNet_ReLU['test_accuracy_history'])*100, '-m', label='ReLU_test')
plt.plot(np.array(DeepConvNet_LeakyReLU['test_accuracy_history'])*100, '-y', label='LeakyReLU_test')
plt.xlabel("Epoch",fontsize=13)
plt.legend(loc='best')
plt.ylabel("Accuracy(%)",fontsize=13)
plt.title("Activation function comparision(DeepConvNet)",fontsize=18)
plt.show()
return "DeepConvNet Accuracy圖繪製成功"
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--plot_loss_curve', action='store_true', help='check if you want to plot the loss curve.')
parser.add_argument('--plot_EEGNet_accuracy_curve', action='store_true', help='check if you want to plot the EEGNet accuracy curve.')
parser.add_argument('--plot_DeepConvNet_accuracy_curve', action='store_true', help='check if you want to plot the DeepConvNet accuracy curve.')
opt = parser.parse_args()
path = os.path.abspath(os.path.dirname(__file__))+"/history_csv/"
DeepConvNet_ELU = pd.DataFrame(pd.read_csv(path+"DeepConvNet_ELU.csv",encoding="utf-8-sig"))
DeepConvNet_ReLU = pd.DataFrame(pd.read_csv(path+"DeepConvNet_ReLU.csv",encoding="utf-8-sig"))
DeepConvNet_LeakyReLU = pd.DataFrame(pd.read_csv(path+"DeepConvNet_LeakyReLU.csv",encoding="utf-8-sig"))
EEGNet_ELU = pd.DataFrame(pd.read_csv(path+"EEGNet_ELU.csv",encoding="utf-8-sig"))
EEGNet_ReLU = pd.DataFrame(pd.read_csv(path+"EEGNet_ReLU.csv",encoding="utf-8-sig"))
EEGNet_LeakyReLU = pd.DataFrame(pd.read_csv(path+"EEGNet_LeakyReLU.csv",encoding="utf-8-sig"))
if opt.plot_loss_curve:
plot_loss_curve(DeepConvNet_ELU,DeepConvNet_ReLU,DeepConvNet_LeakyReLU,EEGNet_ELU,EEGNet_ReLU,EEGNet_LeakyReLU)
if opt.plot_EEGNet_accuracy_curve:
plot_EEGNet_accuracy_curve(DeepConvNet_ELU,DeepConvNet_ReLU,DeepConvNet_LeakyReLU,EEGNet_ELU,EEGNet_ReLU,EEGNet_LeakyReLU)
if opt.plot_DeepConvNet_accuracy_curve:
plot_DeepConvNet_accuracy_curve(DeepConvNet_ELU,DeepConvNet_ReLU,DeepConvNet_LeakyReLU,EEGNet_ELU,EEGNet_ReLU,EEGNet_LeakyReLU)