def main(argv): # if len(argv) > 1: # raise app.UsageError('Too many command-line arguments.') # # runner_lib.load_gin_configs(FLAGS.gin_files, FLAGS.gin_bindings) seed = 0 slate_size = 2 np.random.seed(seed) env_config = { 'num_candidates': 5, 'slate_size': slate_size, 'resample_documents': True, 'seed': seed, } tmp_base_dir = 'C:/Users/Moham/PycharmProjects/ExpertDrivenRec/testing/' runner = runner_lib.TrainRunner( base_dir=tmp_base_dir, create_agent_fn=create_agent, env=interest_evolution.create_environment(env_config), episode_log_file='', max_training_steps=50, num_iterations=10) runner.run_experiment() runner = runner_lib.EvalRunner( base_dir=tmp_base_dir, create_agent_fn=create_agent, env=interest_evolution.create_environment(env_config), max_eval_episodes=5, test_mode=True) runner.run_experiment()
def main(argv): if len(argv) > 1: raise app.UsageError('Too many command-line arguments.') runner_lib.load_gin_configs(FLAGS.gin_files, FLAGS.gin_bindings) seed = 0 slate_size = 2 np.random.seed(seed) env_config = { 'num_candidates': 5, 'slate_size': slate_size, 'resample_documents': True, 'seed': seed, } runner = runner_lib.TrainRunner( base_dir=FLAGS.base_dir, create_agent_fn=create_agent, env=interest_evolution.create_environment(env_config), episode_log_file=FLAGS.episode_log_file, max_training_steps=50, num_iterations=10) runner.run_experiment() runner = runner_lib.EvalRunner( base_dir=FLAGS.base_dir, create_agent_fn=create_agent, env=interest_evolution.create_environment(env_config), max_eval_episodes=5, test_mode=True) runner.run_experiment()
def test_multi_and_single_user_consistency(self, multiuser_env, multiuser_agent, should_succeed): def create_agent(sess, env, summary_writer, eval_mode, multiuser_agent=True): del sess, env, summary_writer, eval_mode # unused action_space = gym.spaces.MultiDiscrete( np.ones((self.slate_size, ))) if multiuser_agent: action_space = gym.spaces.Tuple([action_space] * self.num_users) AgentClass = DummyMultiUserAgent # pylint:disable=invalid-name else: AgentClass = DummySingleUserAgent # pylint:disable=invalid-name return AgentClass(action_space) env_config = dict(multiuser_env=multiuser_env) base_dir = '/tmp/Env%sAgent%s' % (multiuser_env, multiuser_agent) create_agent_fn = functools.partial(create_agent, multiuser_agent=multiuser_agent) if not os.path.exists(base_dir): os.makedirs(base_dir) if should_succeed: # constructors should work _ = runner_lib.TrainRunner(base_dir=base_dir, create_agent_fn=create_agent_fn, env=create_environment(env_config), max_training_steps=1, max_steps_per_episode=1, num_iterations=1) else: # agent constructor should raise error with self.assertRaises(ValueError): _ = runner_lib.TrainRunner(base_dir=base_dir, create_agent_fn=create_agent_fn, env=create_environment(env_config), max_training_steps=1, max_steps_per_episode=1, num_iterations=1)