-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·84 lines (74 loc) · 2.96 KB
/
main.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
from generate_data import generate_data
from Data_processing import pre_process
from train import train
from predict import Prediction
class main():
def __init__(self):
"""
define parameters for training the neural network
"""
self.paramters = {
'Data Size': int(1e3),
'save_data': False,
'Frequency_lb': -3,
'Frequency_ub': 8,
'Samples': 200,
'Scaling': True,
'Scaling Type': ['stand','minmax'],
'Device': 'cuda:2',
'model': 'net1',
'Start Training': False,
'continue_training': False,
'batch_size': 512,
'learning_rate': 1e-4,
'epochs': 100
}
assert not ((self.paramters['continue_training'] == True) and
(self.paramters['Start Training'] == True)), \
'Choose eather a new training or continue Training '
def generate_data(self):
"""
function for generating EIS data from the universal circuit (see paper)
"""
GD = generate_data(size=self.paramters['Data Size'],
w_lb=self.paramters['Frequency_lb'],
w_ub=self.paramters['Frequency_ub'],
samples=self.paramters['Samples'])
return GD.generate()
def preprocess_data(self, data=None):
"""
function for preparing and standardizing the data for the training the testing
"""
PP = pre_process(scale=self.paramters['Scaling'],
scale_type=self.paramters['Scaling Type'][0],
device=self.paramters['Device'],
New_Training=self.paramters['Start Training'],
Neual_Network=self.paramters['model'],
data=data)
return PP.process()
def Train(self, Training_data):
"""
Calls the training module
"""
Training = train(Training_data=Training_data,
device=self.paramters['Device'],
continue_training=self.paramters['continue_training'],
batch_size=self.paramters['batch_size'],
learning_rate=self.paramters['learning_rate'],
epochs=self.paramters['epochs'],
Neual_Network=self.paramters['model'])
Training.start_training()
def Predict(self, Test_data):
"""
Calls the testing module
"""
Pred = Prediction(Test_Data=Test_data,
device=self.paramters['Device'],
Neual_Network=self.paramters['model'])
Pred.predict()
if __name__ == '__main__':
model = main()
data = model.generate_data()
Training_data, Test_data, (Z_real_test_wide, Z_imag_test_wide) = model.preprocess_data(data=data)
#model.Train(Training_data)
model.Predict(Test_data)