-
Notifications
You must be signed in to change notification settings - Fork 2
/
search_optim_eet.py
315 lines (311 loc) · 8.73 KB
/
search_optim_eet.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
import pandas as pd
import numpy as np
import os
import re
import keras
from sklearn.utils import shuffle
from sklearn.model_selection import train_test_split
from numpy import array
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Flatten
from keras.layers import Activation
from keras.layers.convolutional import Conv1D
from keras.layers.convolutional import MaxPooling1D
from hyperopt import Trials, STATUS_OK, tpe
from hyperas import optim
from hyperas.distributions import choice, uniform
# load the trained model
model = keras.models.load_model('../../model-918-tloss-1.474e-07-vloss-1.866e-07.hdf5')
#Show the model architecture
model.summary()
# path to the directory where the training trajectories are stored
gamma = np.arange(5,70)*5
lamb = np.arange(2,70)*5
temp = np.arange(5,70)*5
num_trajs = len(gamma)
# Normalize values range of gamma, lambda and temperature ...
# by dividing each value by the maximum value in that range
#
tt_M = 101 #t_M[f]
# Define logistic function
#
def logistic(x,c):
a=1
b=15
d=1
f= a/(1 + b * np.exp(-(x-c)/d))
return f
# We have seven sites and as a label we use ...
# values between 0 and 1
#
states = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]
#
red_times = 100
t = np.arange(0,1001)*0.005 # 500ps
tt = np.zeros((len(t), red_times), dtype=float)
u=0
for i in t:
c = -1.0
for j in range(0, red_times):
tt[u,j]=logistic(i,c)
c = c + 5
u=u + 1
time_steps = np.arange(0,tt.shape[0]) * 5.0
m = 0
if tt_M <= 201:
for i in range(0,tt_M):
m = m + 1
if tt_M > 201 and tt_M <= 301:
for i in range(0,201):
m = m + 1
for i in range(202,tt_M, 2):
m = m + 1
if tt_M > 301 and tt_M <= 501:
for i in range(0,201):
m = m + 1
for i in range(202,301, 2):
m = m + 1
for i in range(305,tt_M, 5):
m = m + 1
if tt_M > 501 and tt_M <= 1001:
for i in range(0,201):
m = m + 1
for i in range(202,301, 2):
m = m + 1
for i in range(305,501, 5):
m = m + 1
for i in range(510,tt_M, 10):
m = m + 1
if tt_M > 1001 and tt_M <= 5001:
for i in range(0,201):
m = m + 1
for i in range(202,301, 2):
m = m + 1
for i in range(305,501, 5):
m = m + 1
for i in range(510,1001, 10):
m = m + 1
for i in range(1020,tt_M, 20):
m = m + 1
if tt_M > 5001 and tt_M <= 10001:
for i in range(0,201):
m = m + 1
for i in range(202,301, 2):
m = m + 1
for i in range(305,501, 5):
m = m + 1
for i in range(510,1001, 10):
m = m + 1
for i in range(1020,5001, 20):
m = m + 1
for i in range(5040,tt_M, 40):
m = m + 1
if tt_M > 10001 and tt_M <= 50001:
for i in range(0,201):
m = m + 1
for i in range(202,301, 2):
m = m + 1
for i in range(305,501, 5):
m = m + 1
for i in range(510,1001, 10):
m = m + 1
for i in range(1020,5001, 20):
m = m + 1
for i in range(5040,10001, 40):
m = m + 1
for i in range(10100,tt_M, 100):
m = m + 1
if tt_M > 50001:
for i in range(0,201):
m = m + 1
for i in range(202,301, 2):
m = m + 1
for i in range(305,501, 5):
m = m + 1
for i in range(510,1001, 10):
m = m + 1
for i in range(1020,5001, 20):
m = m + 1
for i in range(5040,10001, 40):
m = m + 1
for i in range(10100,50001, 100):
m = m + 1
for i in range(50200,tt_M, 200):
m = m + 1
x = np.zeros((m, 5+red_times), dtype=float)
tf = np.zeros((m,1), dtype = float)
#m = m + 1 # include the t -> infinity
# m is the total number of training points
m = 0
if tt_M < 201:
for i in range(0,tt_M):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
if tt_M > 201 and tt_M <= 301:
for i in range(0,201):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(202,tt_M, 2):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
if tt_M > 301 and tt_M <= 501:
for i in range(0,201):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(202,301, 2):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(305,tt_M, 5):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
if tt_M > 501 and tt_M <= 1001:
for i in range(0,201):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(202,301, 2):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(305,501, 5):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(510,tt_M, 10):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
if tt_M > 1001 and tt_M <= 5001:
for i in range(0,201):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(202,301, 2):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(305,501, 5):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(510,1001, 10):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(1020,tt_M, 20):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
if tt_M > 5001 and tt_M <= 10001:
for i in range(0,201):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(202,301, 2):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(305,501, 5):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(510,1001, 10):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(1020,5001, 20):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(5040,tt_M, 40): # 200fs
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
if tt_M > 10001 and tt_M <= 50001:
for i in range(0,201):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(202,301, 2):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(305,501, 5):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(510,1001, 10):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(1020,5001, 20):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(5040,10001, 40): # 200fs
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(10100,tt_M, 100): #500fs
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
if tt_M > 50001:
for i in range(0,201):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(202,301, 2):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(305,501, 5):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(510,1001, 10):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(1020,5001, 20):
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(5040,10001, 40): # 200fs
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(10100,50001, 100): #500fs
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
for i in range(50200,tt_M, 200): # 1ps
x[m,5:x.shape[1]] = tt[i,:]
tf[m,0] = time_steps[i]
m = m + 1
y_pred = np.zeros((1,13), dtype = float)
for f in range(0,2):
x[:,0] = f
x[:,1] = 0.3
if f == 0:
index = 1
else:
index = 6
for tmp in temp:
x[:,4] = tmp/310
for g in gamma:
x[:,2] = g/300
for l in lamb:
x[:,3] = l/310
x_pred = x[tt_M-1,:]
x_pred = x_pred.reshape(1, x.shape[1],1) # reshape the input
y_pred[0,:] = model.predict(x_pred, verbose=0)
parameters = str(index) + "_gamma-" + str(int(g)) + "_lambda-" + str(int(l)) + "_temp-" + str(int(tmp))
print(parameters, y_pred[0,4])