Exemplo n.º 1
0
 def load_model(self):
     from agent.model import GameModel
     model = GameModel(self.config)
     if self.config.opts.new or not load_best_model_weight(model):
         model.build()
         save_as_best_model(model)
     return model
Exemplo n.º 2
0
    def load_model(self):
        for entry in self.dbx.files_list_folder('/model').entries:
            if entry.name != 'next_generation':
                md, res = self.dbx.files_download('/model/' + entry.name)
                with open(
                        'SantoriniAZ-Dist/SmallSanto - Distributed/data/model/'
                        + entry.name, 'wb') as f:
                    #with open('./data/model/'+entry.name, 'wb') as f:
                    f.write(res.content)

        from agent.model import GameModel
        model = GameModel(self.config)
        rc = self.config.resource

        dirs = get_next_generation_model_dirs(rc)
        if not dirs:
            print("loading best model")
            if not load_best_model_weight(model):
                print("Best model can not loaded!")
        else:
            latest_dir = dirs[-1]
            print("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
Exemplo n.º 3
0
 def load_next_generation_model(self):
     rc = self.config.resource
     while True:
         dirs = get_next_generation_model_dirs(self.config.resource)
         if dirs:
             break
         print("There is no next generation model to evaluate")
         sleep(600)
     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 = GameModel(self.config)
     model.load(config_path, weight_path)
     return model, model_dir
Exemplo n.º 4
0
    def load_model(self):
        from agent.model import GameModel
        model = GameModel(self.config)
        rc = self.config.resource

        dirs = get_next_generation_model_dirs(rc)
        if not dirs:
            print("loading best model")
            if not load_best_model_weight(model):
                #raise RuntimeError(f"Best model can not loaded!")
                print("Best model can not loaded!")
        else:
            latest_dir = dirs[-1]
            print("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
Exemplo n.º 5
0
 def load_best_model(self):
     model = GameModel(self.config)
     load_best_model_weight(model)
     return model
Exemplo n.º 6
0
 def _load_model(self):
     from agent.model import GameModel
     model = GameModel(self.config)
     if not load_best_model_weight(model):
         print("best model not found!")
     return model