def _trigger_epoch(self): if FEATURE: if self.epoch_num % 1 == 0: logger.info("update density network at epoch %d." % (self.epoch_num)) cfg = PredictConfig(session_init=JustCurrentSession(), model=Model(), input_var_names=['state'], output_var_names=[FEATURE]) self.offline_predictor = get_predict_func(cfg)
def run_submission(cfg, dump_dir='gym-submit'): dirname = dump_dir player = get_player(dumpdir=dirname) # player = get_player("/home/piotr.milos") predfunc = get_predict_func(cfg) for k in range(10): if k != 0: player.restart_episode() score = play_one_episode(player, predfunc) print("Total:", score)
def _setup_graph(self): self.sess = self.trainer.sess self.async_predictor = MultiThreadAsyncPredictor( self.trainer.get_predict_funcs(['state'], ['logitsT', 'pred_value'], PREDICTOR_THREAD), batch_size=15) # else: # self.async_predictor = MultiThreadAsyncPredictor( # self.trainer.get_predict_funcs(['state'], ['logitsT', 'pred_value', FEATURE], # PREDICTOR_THREAD), batch_size=15) if FEATURE: logger.info("Initialize density network") cfg = PredictConfig( session_init=NewSession(), model=Model(), input_var_names=['state'], output_var_names=[FEATURE]) self.offline_predictor = get_predict_func(cfg) self.async_predictor.run()
def eval_model_multithread(cfg, nr_eval): func = get_predict_func(cfg) NR_PROC = min(multiprocessing.cpu_count() // 2, 8) mean, max = eval_with_funcs([func] * NR_PROC, nr_eval) logger.info("Average Score: {}; Max Score: {}".format(mean, max))
def play_model(cfg): player = get_player(viz=0.01) predfunc = get_predict_func(cfg) while True: score = play_one_episode(player, predfunc) print("Total:", score)