Exemple #1
0
 def load_model(self):
     from chess_zero.agent.model_chess import ChessModel
     model = ChessModel(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_model(self):
        """
        Loads the next generation model from the appropriate directory. If not found, loads
        the best known model.
        """
        model = ChessModel(self.config)
        rc = self.config.resource

        dirs = get_next_generation_model_dirs(rc)
        if not dirs:
            logger.debug("loading best model")
            if self.config.opts.new and not load_best_model_weight(model):
                model.build()
                save_as_best_model(model)
            elif not load_best_model_weight(model):
                raise RuntimeError("Best model can not loaded!")
        else:
            latest_dir = dirs[-1]
            logger.debug("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
Exemple #3
0
 def load_model(self):
     """
     Load the current best model
     :return ChessModel: current best model
     """
     model = ChessModel(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_model(self):
     model = ChessModel(self.config)
     if self.config.opts.new or not load_newest_model_weight(self.config.resource, model):
         model.build()  # optimize will now _also_ build a new model from scratch if none exists.
         save_as_newest_model(self.config.resource, model)
     return model
Exemple #5
0
 def load_model(self):
     model = ChessModel(self.config)
     if self.config.opts.new or not load_best_model_weight(model):
         model.build()
         save_as_best_model(model)
     return model