2 This is the plot module. 6 __author__ =
'Saul Alonso-Monsalve' 7 __email__ =
"saul.alonso.monsalve@cern.ch" 15 from os
import listdir
16 from os.path
import isfile, join
17 from keras.models
import load_model
18 from keras.utils
import plot_model
21 **************************************** 22 ************** PARAMETERS ************** 23 **************************************** 26 logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
28 config = configparser.ConfigParser()
29 config.read(
'config/config.ini')
33 CHECKPOINT_PATH = config[
'model'][
'checkpoint_path']
34 CHECKPOINT_PREFIX = config[
'model'][
'checkpoint_prefix']
35 CHECKPOINT_SAVE_MANY = ast.literal_eval(config[
'model'][
'checkpoint_save_many'])
36 CHECKPOINT_SAVE_BEST_ONLY = ast.literal_eval(config[
'model'][
'checkpoint_save_best_only'])
37 PRINT_SUMMARY = ast.literal_eval(config[
'model'][
'print_summary'])
41 **************************************** 42 ************** LOAD MODEL ************** 43 **************************************** 48 logging.info(
'Loading model from disk...')
50 if CHECKPOINT_SAVE_MANY:
54 files = [f
for f
in listdir(CHECKPOINT_PATH)
if isfile(join(CHECKPOINT_PATH, f))]
55 files.sort(reverse=
True)
57 r = re.compile(CHECKPOINT_PREFIX[1:] +
'-.*-.*.h5')
60 if r.match(fil)
is not None:
68 model =
load_model(CHECKPOINT_PATH + CHECKPOINT_PREFIX +
'.h5')
75 plot_model(model, to_file=
'model.pdf', show_shapes=
'True')