hive.runners.base module

class hive.runners.base.Runner(environment, agents, logger, experiment_manager, train_steps, eval_environment=None, test_frequency=-1, test_episodes=1, max_steps_per_episode=1000000000.0)[source]

Bases: ABC, Registrable

Base Runner class used to implement a training loop.

Different types of training loops can be created by overriding the relevant functions.

Parameters
  • environment (BaseEnv) – Environment used in the training loop.

  • agents (list[Agent]) – List of agents that interact with the environment.

  • logger (ScheduledLogger) – Logger object used to log metrics.

  • experiment_manager (Experiment) – Experiment object that saves the state of the training.

  • train_steps (int) – How many steps to train for. This is the number of times that agent.update is called. If this is -1, there is no limit for the number of training steps.

  • test_frequency (int) – After how many training steps to run testing episodes. If this is -1, testing is not run.

  • test_episodes (int) – How many episodes to run testing for.

register_config(config)[source]
train_mode(training)[source]

If training is true, sets all agents to training mode. If training is false, sets all agents to eval mode.

Parameters

training (bool) – Whether to be in training mode.

create_episode_metrics()[source]

Create the metrics used during the loop.

update_step()[source]

Update steps for various schedules. Run testing if appropriate.

run_episode(environment)[source]

Run a single episode of the environment.

Parameters

environment (BaseEnv) – Environment in which the agent will take a step in.

run_training()[source]

Run the training loop. Note, to ensure that the test phase is run during the individual runners must call update_step() in their run_episode() methods. See SingleAgentRunner and MultiAgentRunner for examples.

run_testing()[source]

Run a testing phase.

resume()[source]

Resume a saved experiment.

classmethod type_name()[source]
Returns

“runner”