hooks

class rl.hooks.hook.Hook(agent_id='default', experiment_id='default')[source]

The abstract Hook class. A hook is designed to be a callable running on an agent object. It shouldn’t return anything and instead exports the data itself (e.g. pickle, image). It is run at the end of each step.

The hook API relies on the following agent attributes, always available:

  • agent.training: boolean: Whether the agent is in training mode
  • agent.step: int: the step number. Begins to 1.
  • agent.reward: The reward of the current step
  • agent.episode: int: The current episode. Begins to 1.
  • agent.episode_step: int: The step count in the current episode. Begins to 1.
  • agent.done: Whether the episode is terminated
  • agent.step_summaries: A list of summaries of the current step

These variables may also be available: * agent.episode_reward: The cumulated reward of the current episode * agent.observation: The observation at the beginning of the step * agent.observation_1: The observation at the end of the step * agent.action: The action taken during the step * agent.policy * agent.goal * agent.achievement * agent.error

Parameters:
  • agent – the RL agent
  • episodic – Whether the hook will use episode information
agent_init()[source]

Callback that is called when the agent is initialized

experiment_init()[source]

Callback that is called when the experiment is initialized

experiments_init()[source]

Callback that is called when the experiments object is initialized

class rl.hooks.hook.ValidationHook(*args, **kwargs)[source]

Perform validation of the hooks variables at runtime