Monitor Wrapper¶
-
class
stable_baselines3.common.monitor.
Monitor
(env: gym.core.Env, filename: Optional[str] = None, allow_early_resets: bool = True, reset_keywords: Tuple[str, …] = (), info_keywords: Tuple[str, …] = ())[source]¶ A monitor wrapper for Gym environments, it is used to know the episode reward, length, time and other data.
- Parameters
env – (gym.Env) The environment
filename – (Optional[str]) the location to save a log file, can be None for no log
allow_early_resets – (bool) allows the reset of the environment before it is done
reset_keywords – (Tuple[str, …]) extra keywords for the reset call, if extra parameters are needed at reset
info_keywords – (Tuple[str, …]) extra information to log, from the information return of env.step()
-
get_episode_lengths
() → List[int][source]¶ Returns the number of timesteps of all the episodes
- Returns
([int])
-
get_episode_rewards
() → List[float][source]¶ Returns the rewards of all the episodes
- Returns
([float])
-
get_episode_times
() → List[float][source]¶ Returns the runtime in seconds of all the episodes
- Returns
([float])
-
reset
(**kwargs) → numpy.ndarray[source]¶ Calls the Gym environment reset. Can only be called if the environment is over, or if allow_early_resets is True
- Parameters
kwargs – Extra keywords saved for the next episode. only if defined by reset_keywords
- Returns
(np.ndarray) the first observation of the environment