def load_model(self): from agent.model_connect4 import Connect4Model model = Connect4Model(self.config) if self.config.opts.new or not load_best_model_weight(model): model.build() save_as_best_model(model) return model
def load_next_generation_model(self): rc = self.config.resource while True: dirs = get_next_generation_model_dirs(self.config.resource) if dirs: break logger.info(f"There is no next generation model to evaluate") sleep(60) model_dir = dirs[-1] if self.config.eval.evaluate_latest_first else dirs[0] config_path = os.path.join(model_dir, rc.next_generation_model_config_filename) weight_path = os.path.join(model_dir, rc.next_generation_model_weight_filename) model = Connect4Model(self.config) model.load(config_path, weight_path) return model, model_dir
def load_model(self): from agent.model_connect4 import Connect4Model model = Connect4Model(self.config) rc = self.config.resource dirs = get_next_generation_model_dirs(rc) if not dirs: logger.debug(f"loading best model") if not load_best_model_weight(model): raise RuntimeError(f"Best model can not loaded!") else: latest_dir = dirs[-1] logger.debug(f"loading latest model") config_path = os.path.join( latest_dir, rc.next_generation_model_config_filename) weight_path = os.path.join( latest_dir, rc.next_generation_model_weight_filename) model.load(config_path, weight_path) return model
def _load_model(self): from agent.model_connect4 import Connect4Model model = Connect4Model(self.config) if not load_best_model_weight(model): raise RuntimeError("best model not found!") return model
def load_best_model(self): model = Connect4Model(self.config) load_best_model_weight(model) return model