-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_notebook.py
80 lines (60 loc) · 2.23 KB
/
run_notebook.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
from pathlib import Path
import splitter
import json
from pprint import pprint
import grid_search
ROOT_FOLDER_PATH = "history"
BATCH_FILE_NAME = "batch.json"
EPOCH_FILE_NAME = "epoch.json"
MODEL_FILE = "model.txt"
def run_notebook() :
splitter.split_input()
pprint("***** Starting execution of notebook")
grid_search.run()
pprint("***** Ending execution of notebook")
def process_CNN_results( mode, chart_type = None ):
FOLDER_PATH = ROOT_FOLDER_PATH + "/" + mode
results = {}
result_folder = Path( FOLDER_PATH )
sub_folder_list = [str(f) for f in result_folder.glob('**/*') if f.is_dir()]
for folder in sub_folder_list :
if chart_type is None :
my_file = Path( folder + "/" + BATCH_FILE_NAME )
else :
my_file = Path( folder + "/" + EPOCH_FILE_NAME )
if my_file.is_file():
data = json.load( open( str(my_file) ) )
# pprint( data )
if chart_type is None : # in case of batch.json
results[ folder.split("/")[-1] ] = data['loss']
else :
if None in data[chart_type] : # null is parsed as None in Python, smart boy/girl
pass #TODO check for multiple entries
else :
results[ folder.split("/")[-1] ] = data[chart_type] #add entry for chart type
if results:
return results
return None
def process_model_info( mode ):
FOLDER_PATH = ROOT_FOLDER_PATH + "/" + mode
results = {}
my_file = Path( FOLDER_PATH + "/" + MODEL_FILE )
if my_file.is_file():
data = json.load( open( str(my_file) ) )
# pprint( data )
if "model" in data :
results['model'] = data['model']
if 'loss' in data :
results['current_loss'] = data['loss']
else:
results['current_loss'] = ""
if 'acc' in data :
results['current_accuracy'] = data['acc']
else:
results['current_accuracy'] = ""
if results:
return results
return None
if __name__ == '__main__' :
#run_notebook()
process_CNN_results()