Beispiel #1
0
 def load_model(self, path, model_name=None):
     if model_name is not None:
         # # TODO:
         print("specific model loading not yet implemented")
     else:
         pass
     # alweys leads the latest model
     subdirs = all_subdirs_of(path)
     latest_subdir = max(subdirs, key=os.path.getmtime)
     print("loading model...")
     model = tf.keras.models.load_model(latest_subdir)
     weights = model.get_weights()
     self.set_agent(weights)
     agent = self.get_agent()
     return agent
Beispiel #2
0
 def load_model(self, path, model_name=None, compile=False):
     if model_name is not None:
         # # TODO:
         print("specific model loading not yet implemented")
     else:
         pass
     # alweys leads the latest model
     subdirs = all_subdirs_of(path)
     latest_subdir = max(subdirs, key=os.path.getmtime)
     epoch_offset = int(re.findall(
         r"_\d+_",
         latest_subdir)[0][1:-1])  # regex return e.g. ['_25_', '_2021_']
     print("loading model...")
     model = tf.keras.models.load_model(latest_subdir, compile=compile)
     weights = model.get_weights()
     self.set_agent(weights)
     agent = self.get_agent()
     return agent, epoch_offset