bettermdptools.utils.callbacks API documentation

# bettermdptools.utils.callbacks

Author: John Mansfield

View Source

     1# -*- coding: utf-8 -*-
     2"""
     3Author: John Mansfield
     4"""
     5
     6
     7class Callbacks:
     8    """
     9    Base class.
    10    """
    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
    26
    27
    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
    34    def __init__(self):
    35        pass
    36
    37    def on_episode(self, caller, episode):
    38        """
    39        Parameters
    40        ----------------------------
    41        caller (RL type): Calling object
    42
    43        episode {int}: Current episode from caller
    44        """
    45        # do things on specific episodes
    46        pass
    47
    48    def on_episode_begin(self, caller):
    49        """
    50        Parameters
    51        ----------------------------
    52        caller (RL type): Calling object
    53        """
    54        # do things on episode begin
    55        pass
    56
    57    def on_episode_end(self, caller):
    58        """
    59        Parameters
    60        ----------------------------
    61        caller (RL type): Calling object
    62        """
    63        # do things on episode end
    64        pass
    65
    66    def on_env_step(self, caller):
    67        """
    68        Parameters
    69        ----------------------------
    70        caller (RL type): Calling object
    71        """
    72        # do things on env. step
    73        pass

class Callbacks: View Source

     8class Callbacks:
     9    """
    10    Base class.
    11    """
    12
    13    def __init__(self):
    14        pass
    15
    16    def on_episode_begin(self, caller):
    17        pass
    18
    19    def on_episode_end(self, caller):
    20        pass
    21
    22    def on_episode(self, caller, episode):
    23        pass
    24
    25    def on_env_step(self, caller):
    26        pass

Base class.

def on_episode_begin(self, caller): View Source

    16    def on_episode_begin(self, caller):
    17        pass

def on_episode_end(self, caller): View Source

    19    def on_episode_end(self, caller):
    20        pass

def on_episode(self, caller, episode): View Source

    22    def on_episode(self, caller, episode):
    23        pass

def on_env_step(self, caller): View Source

    25    def on_env_step(self, caller):
    26        pass

class MyCallbacks(Callbacks): View Source

    29class MyCallbacks(Callbacks):
    30    """
    31    To create a callback, override one of the callback functions in the child class MyCallbacks.
    32    RL algorithms SARSA and Q-learning have callback hooks for episode number, begin, end, and env. step.
    33    """
    34
    35    def __init__(self):
    36        pass
    37
    38    def on_episode(self, caller, episode):
    39        """
    40        Parameters
    41        ----------------------------
    42        caller (RL type): Calling object
    43
    44        episode {int}: Current episode from caller
    45        """
    46        # do things on specific episodes
    47        pass
    48
    49    def on_episode_begin(self, caller):
    50        """
    51        Parameters
    52        ----------------------------
    53        caller (RL type): Calling object
    54        """
    55        # do things on episode begin
    56        pass
    57
    58    def on_episode_end(self, caller):
    59        """
    60        Parameters
    61        ----------------------------
    62        caller (RL type): Calling object
    63        """
    64        # do things on episode end
    65        pass
    66
    67    def on_env_step(self, caller):
    68        """
    69        Parameters
    70        ----------------------------
    71        caller (RL type): Calling object
    72        """
    73        # do things on env. step
    74        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): View Source

    38    def on_episode(self, caller, episode):
    39        """
    40        Parameters
    41        ----------------------------
    42        caller (RL type): Calling object
    43
    44        episode {int}: Current episode from caller
    45        """
    46        # do things on specific episodes
    47        pass

###### Parameters

- caller (RL type) (Calling object):

- episode {int} (Current episode from caller):

def on_episode_begin(self, caller): View Source

    49    def on_episode_begin(self, caller):
    50        """
    51        Parameters
    52        ----------------------------
    53        caller (RL type): Calling object
    54        """
    55        # do things on episode begin
    56        pass

###### Parameters

- caller (RL type) (Calling object):

def on_episode_end(self, caller): View Source

    58    def on_episode_end(self, caller):
    59        """
    60        Parameters
    61        ----------------------------
    62        caller (RL type): Calling object
    63        """
    64        # do things on episode end
    65        pass

###### Parameters

- caller (RL type) (Calling object):

def on_env_step(self, caller): View Source

    67    def on_env_step(self, caller):
    68        """
    69        Parameters
    70        ----------------------------
    71        caller (RL type): Calling object
    72        """
    73        # do things on env. step
    74        pass

###### Parameters

- caller (RL type) (Calling object):