utils.callbacks
Author: John Mansfield
1# -*- coding: utf-8 -*- 2""" 3Author: John Mansfield 4""" 5 6 7class Callbacks: 8 """ 9 Base class. 10 """ 11 def __init__(self): 12 pass 13 14 def on_episode_begin(self, caller): 15 pass 16 17 def on_episode_end(self, caller): 18 pass 19 20 def on_episode(self, caller, episode): 21 pass 22 23 def on_env_step(self, caller): 24 pass 25 26 27class MyCallbacks(Callbacks): 28 """ 29 To create a callback, override one of the callback functions in the child class MyCallbacks. 30 RL algorithms SARSA and Q-learning have callback hooks for episode number, begin, end, and env. step. 31 """ 32 def __init__(self): 33 pass 34 35 def on_episode(self, caller, episode): 36 """ 37 Parameters 38 ---------------------------- 39 caller (RL type): Calling object 40 41 episode {int}: Current episode from caller 42 """ 43 # do things on specific episodes 44 pass 45 46 def on_episode_begin(self, caller): 47 """ 48 Parameters 49 ---------------------------- 50 caller (RL type): Calling object 51 """ 52 # do things on episode begin 53 pass 54 55 def on_episode_end(self, caller): 56 """ 57 Parameters 58 ---------------------------- 59 caller (RL type): Calling object 60 """ 61 # do things on episode end 62 pass 63 64 def on_env_step(self, caller): 65 """ 66 Parameters 67 ---------------------------- 68 caller (RL type): Calling object 69 """ 70 # do things on env. step 71 pass 72
class
Callbacks:
8class Callbacks: 9 """ 10 Base class. 11 """ 12 def __init__(self): 13 pass 14 15 def on_episode_begin(self, caller): 16 pass 17 18 def on_episode_end(self, caller): 19 pass 20 21 def on_episode(self, caller, episode): 22 pass 23 24 def on_env_step(self, caller): 25 pass
Base class.
28class MyCallbacks(Callbacks): 29 """ 30 To create a callback, override one of the callback functions in the child class MyCallbacks. 31 RL algorithms SARSA and Q-learning have callback hooks for episode number, begin, end, and env. step. 32 """ 33 def __init__(self): 34 pass 35 36 def on_episode(self, caller, episode): 37 """ 38 Parameters 39 ---------------------------- 40 caller (RL type): Calling object 41 42 episode {int}: Current episode from caller 43 """ 44 # do things on specific episodes 45 pass 46 47 def on_episode_begin(self, caller): 48 """ 49 Parameters 50 ---------------------------- 51 caller (RL type): Calling object 52 """ 53 # do things on episode begin 54 pass 55 56 def on_episode_end(self, caller): 57 """ 58 Parameters 59 ---------------------------- 60 caller (RL type): Calling object 61 """ 62 # do things on episode end 63 pass 64 65 def on_env_step(self, caller): 66 """ 67 Parameters 68 ---------------------------- 69 caller (RL type): Calling object 70 """ 71 # do things on env. step 72 pass
To create a callback, override one of the callback functions in the child class MyCallbacks. RL algorithms SARSA and Q-learning have callback hooks for episode number, begin, end, and env. step.
def
on_episode(self, caller, episode):
36 def on_episode(self, caller, episode): 37 """ 38 Parameters 39 ---------------------------- 40 caller (RL type): Calling object 41 42 episode {int}: Current episode from caller 43 """ 44 # do things on specific episodes 45 pass
Parameters
caller (RL type) (Calling object):
episode {int} (Current episode from caller):
def
on_episode_begin(self, caller):
47 def on_episode_begin(self, caller): 48 """ 49 Parameters 50 ---------------------------- 51 caller (RL type): Calling object 52 """ 53 # do things on episode begin 54 pass
Parameters
- caller (RL type) (Calling object):