File size: 26,462 Bytes
b4c5d36 |
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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
"""This file is for creating and training the neural network models for eye movement prediction. Also, this is for creating and training
The in-out model which is for predicting whether the subject is looking inside of the screen or outside of the screen. To understand this
module, you should know about how to build neural network models with keras and tensorflow"""
from tensorflow.keras.layers import (Input, Conv2D, Flatten, MaxPooling2D,
Dense, Concatenate)
from tensorflow.keras.models import Model
import numpy as np
import os
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.models import load_model
from sklearn.preprocessing import StandardScaler
from sklearn.utils import shuffle
from joblib import dump as j_dump
from joblib import load as j_load
import random
from codes.base import eyeing as ey
from openpyxl import Workbook
class Modeling():
@staticmethod
def create_io():
"""
creating in-out model (a CNN model) using tensorflow and keras
Parameters:
None
Returns:
None
"""
print("Starting to create an empty in_out model...")
inp1_shape = (ey.EYE_SIZE[0], ey.EYE_SIZE[1]*2, 1)
x2_chosen_features = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
inp2_shape = (len(x2_chosen_features),)
inp1 = Input(inp1_shape)
layer = Conv2D(16, (11, 11), (1, 1), 'same', activation='relu')(inp1)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Conv2D(32, (7, 7), (1, 1), 'same', activation='relu')(layer)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Conv2D(64, (5, 5), (1, 1), 'same', activation='relu')(layer)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Conv2D(128, (3, 3), (1, 1), activation='relu')(layer)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Flatten()(layer)
inp2 = Input(inp2_shape)
layer = Concatenate()([layer, inp2])
layer = Dense(256, 'relu')(layer)
layer = Dense(128, 'relu')(layer)
layer = Dense(32, 'relu')(layer)
layer = Dense(8, 'relu')(layer)
output_layer = Dense(1, "sigmoid")(layer)
input_layers = [inp1, inp2]
model = Model(inputs=input_layers, outputs=output_layer)
model.compile(optimizer="adam", loss="binary_crossentropy", metrics="acc")
print(model.summary())
n_weights = np.sum([np.prod(v.get_shape()) for v in model.trainable_weights])
mdl_num = ey.find_max_mdl(ey.io_raw_dir) + 1
info = {"n_weights": n_weights,
"input1_shape": inp1_shape,
"input2_shape": inp2_shape,
"x2_chosen_features": x2_chosen_features}
mdl_name = ey.MDL + f"{mdl_num}"
mdl_dir = ey.io_raw_dir + mdl_name + ".h5"
model.save(mdl_dir)
ey.save([info], ey.io_raw_dir, [mdl_name])
print("\nEmpty in_out model created and saved to " + mdl_dir)
@staticmethod
def create_et():
"""
Creating eye tracking model (CNN model) using tensorflow and keras. You can change the structure in following, as you want.
Parameters:
None
Returns:
None
"""
print("Starting to create empty eye_tracking models...")
inp1_shape = (ey.EYE_SIZE[0], ey.EYE_SIZE[1]*2, 1)
x2_chosen_features = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
inp2_shape = (len(x2_chosen_features),)
inp1 = Input(inp1_shape)
layer = Conv2D(16, (11, 11), (1, 1), 'same', activation='relu')(inp1)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Conv2D(32, (7, 7), (1, 1), 'same', activation='relu')(layer)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Conv2D(64, (5, 5), (1, 1), 'same', activation='relu')(layer)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Conv2D(128, (3, 3), (1, 1), activation='relu')(layer)
layer = MaxPooling2D((2, 2), (2, 2))(layer)
layer = Flatten()(layer)
inp2 = Input(inp2_shape)
layer = Concatenate()([layer, inp2])
layer = Dense(256, 'relu')(layer)
layer = Dense(128, 'relu')(layer)
layer = Dense(32, 'relu')(layer)
layer = Dense(8, 'relu')(layer)
out = Dense(1, 'linear')(layer)
input_layers = [inp1, inp2]
model = Model(inputs=input_layers, outputs=out)
model.compile(optimizer='adam', loss='mse')
print(model.summary())
n_weights = np.sum([np.prod(v.get_shape()) for v in model.trainable_weights])
mdl_num = ey.find_max_mdl(ey.et_raw_dir) + 1
info = {"n_weights": n_weights,
"input1_shape": inp1_shape,
"input2_shape": inp2_shape,
"x2_chosen_features": x2_chosen_features}
mdl_name = ey.MDL + f"{mdl_num}"
mdl_dir = ey.et_raw_dir + mdl_name + ".h5"
model.save(mdl_dir)
ey.save([info], ey.et_raw_dir, [mdl_name])
print("\nEmpty eye_tracking model created and saved to " + mdl_dir)
@staticmethod
def train_io(
subjects,
models_list,
min_max_brightness_ratio=[[0.65, 1.45]],
r_train_list=[0.85],
n_epochs_patience=[[160, 10]],
save_scaler=False,
show_model=False
):
"""
Training the io models. This method uses the dataset in the io folder of subject's number folder. The parameters should be lists.
So, you can train each model with several parameters and hyper parameters to see which one works better.
Parameters:
subjects: a list of subject numbers that you want to train the model with them.
models_list: You can train several models at a same time. So, you can enter a list of model numbers
min_max_brightness_ratio: To make the models robust to the brightness, the eyes images are multiplies into a number between two considered numbers
r_train_list: The ratio for train dataset
n_epochs_patience: The number of epochs and patience to intrupt training
save_scaler: To save the scaler
show_model: To show the model
Returns:
None
"""
print("Starting to train in_out model...")
# Loading all subjects
x1_load = []
x2_load = []
y_load = []
for sbj in subjects:
data_io_dir = ey.create_dir([ey.subjects_dir, f"{sbj}", ey.IO])
x1_load0, x2_load0, y_load0 = ey.load(data_io_dir, [ey.X1, ey.X2, ey.Y])
for (x10, x20, y10) in zip(x1_load0[0], x2_load0[0], y_load0[0]):
x1_load.append(x10)
x2_load.append(x20)
y_load.append(y10)
x1_load = np.array(x1_load)
x2_load = np.array(x2_load)
y_load = np.array(y_load)
n_smp = x1_load.shape[0]
print(f"\nNumber of samples : {n_smp}")
# Going through each brightness in min_max_brightness_ratio list
j = 1
for mbr in min_max_brightness_ratio:
x1_new = x1_load.copy()
for (i, _) in enumerate(x1_load):
r = random.uniform(mbr[0], mbr[1])
x1_new[i] = (x1_new[i] * r).astype(np.uint8)
# Going through each model
for raw_mdl_num in models_list:
info = ey.load(ey.io_raw_dir, [ey.MDL + f"{raw_mdl_num}"])[0]
x2_chosen_features = info["x2_chosen_features"]
x2_new = x2_load[:, x2_chosen_features]
x1_shf, x2_shf, y_shf = shuffle(x1_new, x2_new, y_load)
x1_scaler = ey.X1_SCALER
x1 = x1_shf / x1_scaler
x2_scaler = StandardScaler()
x2 = x2_scaler.fit_transform(x2_shf)
scalers = [x1_scaler, x2_scaler]
if save_scaler:
j_dump(scalers, ey.scalers_dir + f"scl_io_{len(x2_chosen_features)}.bin")
# Going through each training ratio in r_train_list
for rt in r_train_list:
n_train = int(rt * n_smp)
x1_train, x2_train = x1[:n_train], x2[:n_train]
x1_val, x2_val = x1[n_train:], x2[n_train:]
y_train = y_shf[:n_train]
y_val = y_shf[n_train:]
print("\nTrain and val data shape:")
print(x1_train.shape, x1_val.shape, x2_train.shape, x2_val.shape,
y_train.shape, y_val.shape)
x_train = [x1_train, x2_train]
x_val = [x1_val, x2_val]
# Going throught each epoch and patience in n_epochs_patience
for nep in n_epochs_patience:
# Training the models
info["min_max_brightness_ratio"] = mbr
info["r_train"] = rt
info["n_epochs_patience"] = nep
cb = EarlyStopping(patience=nep[1], verbose=1, restore_best_weights=True)
raw_model_dir = ey.io_raw_dir + ey.MDL + f"{raw_mdl_num}.h5"
print("\nLoading blink_in_out model from " + raw_model_dir)
model = load_model(raw_model_dir)
if show_model:
print(model.summary())
print(f"\n<<<<<<< {j}-model:{raw_mdl_num}-min_max_ratio:{mbr}-r_train:{rt}-epoch_patience:{nep} >>>>>>>>")
model.fit(x_train,
y_train,
validation_data=(x_val, y_val),
epochs=nep[0],
callbacks=cb)
train_loss = model.evaluate(x_train, y_train)
val_loss = model.evaluate(x_val, y_val)
info["train_loss"] = train_loss
info["val_loss"] = val_loss
trained_mdl_num = ey.find_max_mdl(ey.io_trained_dir) + 1
mdl_name = ey.MDL + f'{trained_mdl_num}'
ey.save([info], ey.io_trained_dir, [mdl_name])
mdl_tr_dir = ey.io_trained_dir + mdl_name + ".h5"
model.save(mdl_tr_dir)
print("\nSaving in_out model in " + mdl_tr_dir)
j += 1
@staticmethod
def train_et(
subjects,
models_list,
min_max_brightness_ratio=[[0.65, 1.45]],
r_train_list=[0.8],
n_epochs_patience=[[100, 15]],
shift_samples=None,
blinking_threshold="d",
save_scaler=False,
show_model=False
):
"""
Training the et (base) models. This method uses the dataset in the et folder of subject's number folder. The parameters should be lists.
So, you can train each model with several parameters and hyper parameters to see which one works better.
Parameters:
subjects: a list of subject numbers that you want to train the model with them.
models_list: You can train several models at a same time. So, you can enter a list of model numbers
min_max_brightness_ratio: To make the models robust to the brightness, the eyes images are multiplies into a number between two considered numbers
r_train_list: The ratio for train dataset
n_epochs_patience: The number of epochs and patience to intrupt training
shift_samples: To shift sample if there is a high delay
blinking_threshold: It can have three types --> d: default, ao: app offered, uo: user offered
save_scaler: To save the scaler
show_model: To show the model
Returns:
None
"""
print("Starting to train eye_tracking models...")
# Loading all subjects
x1_load = []
x2_load = []
y_load = []
kk = 0
for sbj in subjects:
sbj_dir = ey.create_dir([ey.subjects_dir, f"{sbj}"])
sbj_clb_dir = ey.create_dir([sbj_dir, ey.CLB])
(
sbj_x1_load,
sbj_x2_load,
sbj_y_load,
sbj_t_mat,
sbj_eyes_ratio
) = ey.load(sbj_clb_dir, [ey.X1, ey.X2, ey.Y, ey.T, ey.ER])
# If there is any shifting samples, doing that
if shift_samples:
if shift_samples[kk]:
ii = 0
for (x11, x21, y1, t1, eyr1) in zip(sbj_x1_load, sbj_x2_load, sbj_y_load, sbj_t_mat, sbj_eyes_ratio):
sbj_t_mat[ii] = t1[:-shift_samples[kk]]
sbj_x1_load[ii] = x11[shift_samples[kk]:]
sbj_x2_load[ii] = x21[shift_samples[kk]:]
sbj_y_load[ii] = y1[:-shift_samples[kk]]
sbj_eyes_ratio[ii] = eyr1[shift_samples[kk]:]
ii += 1
kk += 1
sbj_er_dir = ey.create_dir([sbj_dir, ey.ER])
# Removing the samples that are during blinking
sbj_blinking_threshold = ey.get_threshold(sbj_er_dir, blinking_threshold)
sbj_blinking = ey.get_blinking(sbj_t_mat, sbj_eyes_ratio, sbj_blinking_threshold)[1]
for (x11, x21, y1, b1) in zip(sbj_x1_load, sbj_x2_load, sbj_y_load, sbj_blinking):
for (x10, x20, y0, b0) in zip(x11, x21, y1, b1):
if not b0:
x1_load.append(x10)
x2_load.append(x20)
y_load.append(y0)
x1_load = np.array(x1_load)
x2_load = np.array(x2_load)
y_load = np.array(y_load)
n_smp = x1_load.shape[0]
print(f"\nNumber of samples : {n_smp}")
# Going through each brightness in min_max_brightness_ratio list
j = 1
for mbr in min_max_brightness_ratio:
x1_new = x1_load.copy()
for (i, _) in enumerate(x1_load):
r = random.uniform(mbr[0], mbr[1])
x1_new[i] = (x1_new[i] * r).astype(np.uint8)
# Going through each model
for raw_mdl_num in models_list:
info = ey.load(ey.et_raw_dir, [ey.MDL + f"{raw_mdl_num}"])[0]
x2_chosen_features = info["x2_chosen_features"]
x2_new = x2_load[:, x2_chosen_features]
x1_shf, x2_shf, y_hrz_shf, y_vrt_shf = shuffle(x1_new, x2_new, y_load[:, 0], y_load[:, 1])
x1_scaler = ey.X1_SCALER
x1 = x1_shf / x1_scaler
x2_scaler = StandardScaler()
x2 = x2_scaler.fit_transform(x2_shf)
y_scaler = ey.Y_SCALER
scalers = [x1_scaler, x2_scaler, y_scaler]
if save_scaler:
j_dump(scalers, ey.scalers_dir + f"scl_et_{len(x2_chosen_features)}.bin")
# Going through each training ratio in r_train_list
for rt in r_train_list:
n_train = int(rt * n_smp)
x1_train, x2_train = x1[:n_train], x2[:n_train]
x1_val, x2_val = x1[n_train:], x2[n_train:]
y_hrz_train, y_vrt_train = y_hrz_shf[:n_train], y_vrt_shf[:n_train]
y_hrz_val, y_vrt_val = y_hrz_shf[n_train:], y_vrt_shf[n_train:]
print("\nTrain and val data shape:")
print(x1_train.shape, x1_val.shape, x2_train.shape, x2_val.shape,
y_hrz_train.shape, y_hrz_val.shape, y_vrt_train.shape, y_vrt_val.shape)
x_train = [x1_train, x2_train]
x_val = [x1_val, x2_val]
# Going throught each epoch and patience in n_epochs_patience
for nep in n_epochs_patience:
# Training the models
info["min_max_brightness_ratio"] = mbr
info["r_train"] = rt
info["n_epochs_patience"] = nep
cb = EarlyStopping(patience=nep[1], verbose=1, restore_best_weights=True)
raw_model_dir = ey.et_raw_dir + ey.MDL + f"{raw_mdl_num}.h5"
print("\nLoading eye_tracking model from " + raw_model_dir)
model_hrz = load_model(raw_model_dir)
model_vrt = load_model(raw_model_dir)
if show_model:
print(model_hrz.summary())
trained_mdl_num = ey.find_max_mdl(ey.et_trained_dir, b=-7) + 1
print(f"\n<<<<<<< {j}-model-hrz:{raw_mdl_num}-min_max_ratio:{mbr}-r_train:{rt}-epoch_patience:{nep} >>>>>>>>")
model_hrz.fit(x_train,
y_hrz_train * y_scaler,
validation_data=(x_val, y_hrz_val * y_scaler),
epochs=nep[0],
callbacks=cb)
mdl_name = ey.MDL + f"{trained_mdl_num}"
mdl_hrz_tr_dir = ey.et_trained_dir + mdl_name + "-hrz.h5"
print("\nSaving horizontally eye_tracking model in " + mdl_hrz_tr_dir)
model_hrz.save(mdl_hrz_tr_dir)
hrz_train_loss = model_hrz.evaluate(x_train, y_hrz_train * y_scaler)
hrz_val_loss = model_hrz.evaluate(x_val, y_hrz_val * y_scaler)
info["hrz_train_loss"] = hrz_train_loss
info["hrz_val_loss"] = hrz_val_loss
print(f"\n<<<<<<< {j}-model-vrt:{raw_mdl_num}-min_max_ratio:{mbr}-r_train:{rt}-epoch_patience:{nep} >>>>>>>>")
model_vrt.fit(x_train,
y_vrt_train * y_scaler,
validation_data=(x_val, y_vrt_val * y_scaler),
epochs=nep[0],
callbacks=cb)
tr_model_vrt_dir = ey.et_trained_dir + mdl_name + f"-vrt.h5"
print("Saving vertically eye_tracking model in " + tr_model_vrt_dir)
model_vrt.save(tr_model_vrt_dir)
vrt_train_loss = model_vrt.evaluate(x_train, y_vrt_train * y_scaler)
vrt_val_loss = model_vrt.evaluate(x_val, y_vrt_val * y_scaler)
info["vrt_train_loss"] = vrt_train_loss
info["vrt_val_loss"] = vrt_val_loss
ey.save([info], ey.et_trained_dir, [mdl_name])
j += 1
@staticmethod
def get_models_information(io=True, raw=True, show_model=False):
"""
To write the models information in an excel file. It gets the information from attached pickle file for each model.
There are raw models and trained models in the io and the et.
Parameters:
io: If it's io or et
raw: If the model is trained or not
show_model: If you want to show the model
Returns:
None
"""
wb = Workbook()
ws = wb.active
ws['A1'] = "# of model"
ws['B1'] = "# of weights"
ws['C1'] = "input 1 shape"
ws['D1'] = "input 2 shape"
ws['E1'] = "x2 chosen features"
if io:
if raw:
files_name = os.listdir(ey.io_raw_dir)
if files_name:
for fn in files_name:
if fn[-7:] == ".pickle":
mdl_num = int(fn[3:-7])
mdl_name = ey.MDL + f"{mdl_num}"
if show_model:
mdl_dir = ey.io_raw_dir + mdl_name + ".h5"
mdl = load_model(mdl_dir)
print(f"<<<<<<<<<<<<<< {mdl_dir} >>>>>>>>>>>>>>")
print(mdl.summary())
info = ey.load(ey.io_raw_dir, [mdl_name])[0]
ws[f'A{mdl_num+1}'] = str(mdl_num)
ws[f'B{mdl_num+1}'] = str(info['n_weights'])
ws[f'C{mdl_num+1}'] = str(info['input1_shape'])
ws[f'D{mdl_num+1}'] = str(info['input2_shape'])
ws[f'E{mdl_num+1}'] = str(info['x2_chosen_features'])
else:
ws['F1'] = "min-Max brightness ratio"
ws['G1'] = "r_train"
ws['H1'] = "# of epochs and patience"
ws['I1'] = "train loss"
ws['J1'] = "val loss"
files_name = os.listdir(ey.io_trained_dir)
if files_name:
for fn in files_name:
if fn[-7:] == ".pickle":
mdl_num = int(fn[3:-7])
mdl_name = ey.MDL + f"{mdl_num}"
if show_model:
mdl_dir = ey.io_trained_dir + mdl_name + ".h5"
mdl = load_model(mdl_dir)
print(f"<<<<<<<<<<<<<< {mdl_dir} >>>>>>>>>>>>>>")
print(mdl.summary())
info = ey.load(ey.io_trained_dir, [mdl_name])[0]
ws[f'A{mdl_num+1}'] = str(mdl_num)
ws[f'B{mdl_num+1}'] = str(info['n_weights'])
ws[f'C{mdl_num+1}'] = str(info['input1_shape'])
ws[f'D{mdl_num+1}'] = str(info['input2_shape'])
ws[f'E{mdl_num+1}'] = str(info['x2_chosen_features'])
ws[f'F{mdl_num+1}'] = str(info['min_max_brightness_ratio'])
ws[f'G{mdl_num+1}'] = str(info['r_train'])
ws[f'H{mdl_num+1}'] = str(info['n_epochs_patience'])
ws[f'I{mdl_num+1}'] = str(info['train_loss'])
ws[f'J{mdl_num+1}'] = str(info['val_loss'])
else:
if raw:
files_name = os.listdir(ey.et_raw_dir)
if files_name:
for fn in files_name:
if fn[-7:] == ".pickle":
mdl_num = int(fn[3:-7])
mdl_name = ey.MDL + f"{mdl_num}"
if show_model:
mdl_dir = ey.et_raw_dir + mdl_name + ".h5"
mdl = load_model(mdl_dir)
print(f"<<<<<<<<<<<<<< {mdl_dir} >>>>>>>>>>>>>>")
print(mdl.summary())
info = ey.load(ey.et_raw_dir, [mdl_name])[0]
ws[f'A{mdl_num+1}'] = str(mdl_num)
ws[f'B{mdl_num+1}'] = str(info['n_weights'])
ws[f'C{mdl_num+1}'] = str(info['input1_shape'])
ws[f'D{mdl_num+1}'] = str(info['input2_shape'])
ws[f'E{mdl_num+1}'] = str(info['x2_chosen_features'])
else:
ws['F1'] = "min-Max brightness ratio"
ws['G1'] = "r_train"
ws['H1'] = "# of epochs and patience"
ws['I1'] = "model-hrz train loss"
ws['J1'] = "model-hrz val loss"
ws['K1'] = "model-vrt train loss"
ws['L1'] = "model-vrt val loss"
files_name = os.listdir(ey.et_trained_dir)
if files_name:
for fn in files_name:
if fn[-7:] == ".pickle":
mdl_num = int(fn[3:-7])
mdl_name = ey.MDL + f"{mdl_num}"
if show_model:
mdl_dir = ey.et_trained_dir + mdl_name + "-hrz.h5"
mdl = load_model(mdl_dir)
print(f"<<<<<<<<<<<<<< {mdl_dir} >>>>>>>>>>>>>>")
print(mdl.summary())
info = ey.load(ey.et_trained_dir, [mdl_name])[0]
ws[f'A{mdl_num+1}'] = str(mdl_num)
ws[f'B{mdl_num+1}'] = str(info['n_weights'])
ws[f'C{mdl_num+1}'] = str(info['input1_shape'])
ws[f'D{mdl_num+1}'] = str(info['input2_shape'])
ws[f'E{mdl_num+1}'] = str(info['x2_chosen_features'])
ws[f'F{mdl_num+1}'] = str(info['min_max_brightness_ratio'])
ws[f'G{mdl_num+1}'] = str(info['r_train'])
ws[f'H{mdl_num+1}'] = str(info['n_epochs_patience'])
ws[f'I{mdl_num+1}'] = str(info['hrz_train_loss'])
ws[f'J{mdl_num+1}'] = str(info['hrz_val_loss'])
ws[f'K{mdl_num+1}'] = str(info['vrt_train_loss'])
ws[f'L{mdl_num+1}'] = str(info['vrt_val_loss'])
if io and raw:
info_name = "info_io_raw"
elif io and not raw:
info_name = "info_io_trained"
elif not io and raw:
info_name = "info_et_raw"
else:
info_name = "info_et_trained"
wb.save(ey.files_dir + info_name + ".xlsx") |