def _setup_nn(self): neural_network.start_nn_server( self.config.nn_server_training_port(), self.nn_name, self.config, log_dir=self.log_dir, start_batch=self.progress.stats.progress.current_batch) self.nn_client = neural_network.NeuralNetworkClient( 'tcp://localhost:{}'.format(self.config.nn_server_training_port())) self.nn_client.start(self.config) if self.progress.stats.progress.iteration > 0: checkpoint_name = 'checkpoint-{0:05d}.zip'.format( self.progress.stats.progress.iteration) with open(os.path.join(self.weights_dir, checkpoint_name), 'rb') as file: weights_binary = file.read() self.nn_client.load_weights(weights_binary) with open(os.path.join(self.work_dir, 'best-checkpoint.zip'), 'rb') as file: self.best_weights_binary = file.read() else: self.progress.stats.progress.iteration = 1 self.best_weights_binary = self.nn_client.save_weights() self._save_best_weights() self.current_weights_binary = self.nn_client.save_weights() self._save_current_weights() self.progress.save_stats()
def _restart_network_two(self, nn_class_name): self.nn_class_name_two = nn_class_name if self.nn_client_two: self.nn_client_two.shutdown_server() self.nn_client_two.stop() time.sleep(15) neural_network.start_nn_server(self.config.nn_server_selfeval_port(), self.nn_class_name_two, self.config) self.nn_client_host_two = 'tcp://localhost:{}'.format(self.config.nn_server_selfeval_port()) self.nn_client_two = neural_network.NeuralNetworkClient(self.nn_client_host_two) self.nn_client_two.start(self.config)
def _restart_network_one(self, nn_class_name): self.nn_class_name_one = nn_class_name if self.nn_client_one: self.nn_client_one.shutdown_server() self.nn_client_one.stop() time.sleep(15) neural_network.start_nn_server(self.config.nn_server_selfplay_port(), self.nn_class_name_one, self.config) self.nn_client_host_one = 'tcp://localhost:{}'.format(self.config.nn_server_selfplay_port()) self.nn_client_one = neural_network.NeuralNetworkClient(self.nn_client_host_one) self.nn_client_one.start(self.config)