schola.scripts.sb3.utils.SingleEnvRewardCallback
Class Definition
class schola.scripts.sb3.utils.SingleEnvRewardCallback(verbose=0, id=0, frequency=10)
Bases: BaseCallback
Callback for logging rewards and steps taken by a single environment inside a vector environment.
Parameters
verbose
Type: int
Verbosity level.
id
Type: int
The id of the environment to log rewards and steps for.
frequency
Type: int
The frequency at which to log the rewards and steps taken.
Attributes
episode_reward
Type: float
The reward for the current episode.
episode_rewards
Type: List[float]
The rewards for each episode.
episode_steps
Type: int
The number of steps taken in the current episode.
id
Type: int
The id of the environment to log rewards and steps for.
last_logging_interval
Type: int
The last interval that was logged.
logger
logging_interval_size
Type: int
The frequency at which to log the rewards and steps taken.
model
ready_to_log
Type: bool
Returns whether the environment is ready to log, by checking if there are more episodes completed than self.logging_interval_size since we last logged.
step_count
Type: List[int]
The number of steps taken in each episode.
Methods
__init__
__init__(verbose=0, id=0, frequency=10)
get_reward_interval
get_reward_interval()
Returns the rewards for the last logging interval.
Returns: The rewards for the last logging interval.
Return type: List[float]
get_step_interval
get_step_interval()
Returns the steps taken for each episode in the last logging interval.
Returns: The steps taken for each episode in the last logging interval.
Return type: List[int]
increment_logging_interval
increment_logging_interval()
Increments the logging interval by self.logging_interval_size steps.
Return type: None
init_callback
init_callback(model)
Initialize the callback by saving references to the RL model and the training environment for convenience.
on_rollout_end
on_rollout_end()
on_rollout_start
on_rollout_start()
on_step
on_step()
This method will be called by the model after each call to env.step()
.
on_training_end
on_training_end()
on_training_start
on_training_start(locals_, globals_)
update_child_locals
update_child_locals(locals_)
Update the references to the local variables on sub callbacks.
update_locals
update_locals(locals_)
Update the references to the local variables.