def start(self): if self.model is None: self.model = self.load_model() self.buffer = [] idx = self.read_as_int(self.config.resource.self_play_game_idx_file) or 1 mtcs_info = None while True: start_time = time() if mtcs_info is None and self.config.play.share_mtcs_info_in_self_play: mtcs_info = ReversiPlayer.create_mtcs_info() env = self.start_game(idx, mtcs_info) end_time = time() logger.debug(f"play game {idx} time={end_time - start_time} sec, " f"turn={env.turn}:{env.board.number_of_black_and_white}:{env.winner}") while True: try: if self.config.play.use_newest_next_generation_model: reload_newest_next_generation_model_if_changed(self.model, clear_session=True) else: reload_best_model_weight_if_changed(self.model, clear_session=True) break except Exception as e: logger.error(e) if idx % self.config.play.reset_mtcs_info_per_game == 0: logger.debug("reset MTCS info") mtcs_info = None idx += 1 with open(self.config.resource.self_play_game_idx_file, "wt") as f: f.write(str(idx))
def try_reload_model(self): try: logger.debug("check model") if self.config.play.use_newest_next_generation_model: reload_newest_next_generation_model_if_changed( self.model, clear_session=True) else: reload_best_model_weight_if_changed(self.model, clear_session=True) except Exception as e: logger.error(e)
def start(self): if self.model is None: self.model = self.load_model() self.buffer = [] idx = 1 while True: start_time = time() self.start_game(idx) end_time = time() logger.debug(f"play game {idx} time={end_time - start_time} sec") if (idx % self.config.play_data.nb_game_in_file) == 0: reload_best_model_weight_if_changed(self.model) idx += 1
def start(self): if self.model is None: self.model = self.load_model() self.buffer = [] idx = 1 mtcs_info = None while True: start_time = time() if mtcs_info is None and self.config.play.share_mtcs_info_in_self_play: mtcs_info = ReversiPlayer.create_mtcs_info() env = self.start_game(idx, mtcs_info) end_time = time() logger.debug( f"play game {idx} time={end_time - start_time} sec, " f"turn={env.turn}:{env.board.number_of_black_and_white}:{env.winner}" ) if self.config.play.use_newest_next_generation_model: model_changed = reload_newest_next_generation_model_if_changed( self.model, clear_session=True) else: model_changed = reload_best_model_weight_if_changed( self.model, clear_session=True) if model_changed: mtcs_info = None idx += 1
def start(self): if self.model is None: self.model = self.load_model() self.buffer = [] idx = 1 while True: start_time = time() env = self.start_game(idx) end_time = time() logger.debug( f"play game {idx} time={end_time - start_time} sec, " f"turn={env.turn}:{env.board.number_of_black_and_white}:{env.winner}" ) if True or (idx % self.config.play_data.nb_game_in_file) == 0: if self.config.play.use_newest_next_generation_model: reload_newest_next_generation_model_if_changed( self.model, clear_session=True) else: if reload_best_model_weight_if_changed(self.model, clear_session=True): self.reset_false_positive_count() idx += 1