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.
- 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.
- 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 theirrun_episode()
methods. SeeSingleAgentRunner
andMultiAgentRunner
for examples.