-
Notifications
You must be signed in to change notification settings - Fork 1
/
tune.py
57 lines (40 loc) · 1.47 KB
/
tune.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
import train
import zipfile
import os
import sys
import shutil
models = ["lstm", "mlp", "covNet"]
layers = [
[64, 128, 256],
[[64], [128], [256]],
[[64, 128], [128, 256], [32, 64]]
]
#train_80_path = 'Data/Train/Train_80_Percent'
#val_10_path = 'Data/Validation/Validation_10_Percent'
#test_10_path = 'Data/Test/Test_10_Percent'
#train_10min_path = 'Data/Train/Under_10_min_training'
#tune_90min_path = 'Data/Train/Under_90_min_tuning'
print(sys.argv[1])
with zipfile.ZipFile(sys.argv[1],"r") as zip_ref:
zip_ref.extractall(".")
os.rename("Temp/processed_data.npy","Temp/Under_90_min_tuning.npy")
with zipfile.ZipFile(sys.argv[2],"r") as zip_ref:
zip_ref.extractall(".")
os.rename("Temp/processed_data.npy","Temp/Validation_10_Percent.npy")
f = open('tuning_results.txt', 'w')
best_rmse = 999999
best_model = ""
best_hyperparameter = ""
for i in range(len(models)):
for j in range(len(layers[i])):
print("Model ",models[i],j)
rmse = train.training(models[i], layers[i][j], 0)
f.write('{}, {}, {}\n'.format(models[i], layers[i][j], rmse))
if rmse < best_rmse:
best_rmse = rmse
best_model = models[i]
best_hyperparameter = layers[i][j]
f.close()
f = open('hyperparameter.txt', 'w')
f.write('{}, {}, {}\n'.format(best_model, best_hyperparameter, best_rmse))
f.close()