Monitor Wrapper¶
- class stable_baselines3.common.monitor.Monitor(env, filename=None, allow_early_resets=True, reset_keywords=(), info_keywords=(), override_existing=True)[source]¶
A monitor wrapper for Gym environments, it is used to know the episode reward, length, time and other data.
- Parameters:
env (
Env) – The environmentfilename (
Optional[str]) – the location to save a log file, can be None for no logallow_early_resets (
bool) – allows the reset of the environment before it is donereset_keywords (
Tuple[str,...]) – extra keywords for the reset call, if extra parameters are needed at resetinfo_keywords (
Tuple[str,...]) – extra information to log, from the information return of env.step()override_existing (
bool) – appends to file iffilenameexists, otherwise override existing files (default)
- get_episode_lengths()[source]¶
Returns the number of timesteps of all the episodes
- Return type:
List[int]- Returns:
- get_episode_rewards()[source]¶
Returns the rewards of all the episodes
- Return type:
List[float]- Returns:
- get_episode_times()[source]¶
Returns the runtime in seconds of all the episodes
- Return type:
List[float]- Returns:
- reset(**kwargs)[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
- Return type:
Tuple[TypeVar(ObsType),Dict[str,Any]]- Returns:
the first observation of the environment
- class stable_baselines3.common.monitor.ResultsWriter(filename='', header=None, extra_keys=(), override_existing=True)[source]¶
A result writer that saves the data from the Monitor class
- Parameters:
filename (
str) – the location to save a log file. When it does not end in the string"monitor.csv", this suffix will be appended to itheader (
Optional[Dict[str,Union[float,str]]]) – the header dictionary object of the saved csvextra_keys (
Tuple[str,...]) – the extra information to log, typically is composed ofreset_keywordsandinfo_keywordsoverride_existing (
bool) – appends to file iffilenameexists, otherwise override existing files (default)