Logger

class stable_baselines3.common.logger.CSVOutputFormat(filename)[source]
close()[source]

closes the file

Return type

None

write(key_values, key_excluded, step=0)[source]

Write a dictionary to file

Parameters
  • key_values (Dict[str, Any]) –

  • key_excluded (Dict[str, Union[str, Tuple[str, …]]]) –

  • step (int) –

Return type

None

class stable_baselines3.common.logger.Figure(figure, close)[source]

Figure data class storing a matplotlib figure and whether to close the figure after logging it

Parameters
  • figure (figure) – figure to log

  • close (bool) – if true, close the figure after logging it

exception stable_baselines3.common.logger.FormatUnsupportedError(unsupported_formats, value_description)[source]
class stable_baselines3.common.logger.HumanOutputFormat(filename_or_file)[source]
close()[source]

closes the file

Return type

None

write(key_values, key_excluded, step=0)[source]

Write a dictionary to file

Parameters
  • key_values (Dict) –

  • key_excluded (Dict) –

  • step (int) –

Return type

None

write_sequence(sequence)[source]

write_sequence an array to file

Parameters

sequence (List) –

Return type

None

class stable_baselines3.common.logger.Image(image, dataformats)[source]

Image data class storing an image and data format

Parameters
  • image (Union[Tensor, ndarray, str]) – image to log

  • dataformats (str) – Image data format specification of the form NCHW, NHWC, CHW, HWC, HW, WH, etc. More info in add_image method doc at https://pytorch.org/docs/stable/tensorboard.html Gym envs normally use ‘HWC’ (channel last)

class stable_baselines3.common.logger.JSONOutputFormat(filename)[source]
close()[source]

closes the file

Return type

None

write(key_values, key_excluded, step=0)[source]

Write a dictionary to file

Parameters
  • key_values (Dict[str, Any]) –

  • key_excluded (Dict[str, Union[str, Tuple[str, …]]]) –

  • step (int) –

Return type

None

class stable_baselines3.common.logger.KVWriter[source]

Key Value writer

close()[source]

Close owned resources

Return type

None

write(key_values, key_excluded, step=0)[source]

Write a dictionary to file

Parameters
  • key_values (Dict[str, Any]) –

  • key_excluded (Dict[str, Union[str, Tuple[str, …]]]) –

  • step (int) –

Return type

None

class stable_baselines3.common.logger.SeqWriter[source]

sequence writer

write_sequence(sequence)[source]

write_sequence an array to file

Parameters

sequence (List) –

Return type

None

class stable_baselines3.common.logger.TensorBoardOutputFormat(folder)[source]
close()[source]

closes the file

Return type

None

write(key_values, key_excluded, step=0)[source]

Write a dictionary to file

Parameters
  • key_values (Dict[str, Any]) –

  • key_excluded (Dict[str, Union[str, Tuple[str, …]]]) –

  • step (int) –

Return type

None

class stable_baselines3.common.logger.Video(frames, fps)[source]

Video data class storing the video frames and the frame per seconds

Parameters
  • frames (Tensor) – frames to create the video from

  • fps (Union[float, int]) – frames per second

stable_baselines3.common.logger.configure(folder=None, format_strings=None)[source]

configure the current logger

Parameters
  • folder (Optional[str]) – the save location (if None, $SB3_LOGDIR, if still None, tempdir/baselines-[date & time])

  • format_strings (Optional[List[str]]) – the output logging format (if None, $SB3_LOG_FORMAT, if still None, [‘stdout’, ‘log’, ‘csv’])

Return type

None

stable_baselines3.common.logger.debug(*args)[source]

Write the sequence of args, with no separators, to the console and output files (if you’ve configured an output file). Using the DEBUG level.

Parameters

args – log the arguments

Return type

None

stable_baselines3.common.logger.dump(step=0)[source]

Write all of the diagnostics from the current iteration

Return type

None

stable_baselines3.common.logger.dump_tabular(step=0)

Write all of the diagnostics from the current iteration

Return type

None

stable_baselines3.common.logger.error(*args)[source]

Write the sequence of args, with no separators, to the console and output files (if you’ve configured an output file). Using the ERROR level.

Parameters

args – log the arguments

Return type

None

stable_baselines3.common.logger.filter_excluded_keys(key_values, key_excluded, _format)[source]

Filters the keys specified by key_exclude for the specified format

Parameters
  • key_values (Dict[str, Any]) – log dictionary to be filtered

  • key_excluded (Dict[str, Union[str, Tuple[str, …]]]) – keys to be excluded per format

  • _format (str) – format for which this filter is run

Return type

Dict[str, Any]

Returns

dict without the excluded keys

stable_baselines3.common.logger.get_dir()[source]

Get directory that log files are being written to. will be None if there is no output directory (i.e., if you didn’t call start)

Return type

str

Returns

the logging directory

stable_baselines3.common.logger.get_level()[source]

Get logging threshold on current logger. :rtype: int :return: the logging level (can be DEBUG=10, INFO=20, WARN=30, ERROR=40, DISABLED=50)

stable_baselines3.common.logger.get_log_dict()[source]

get the key values logs

Return type

Dict

Returns

the logged values

stable_baselines3.common.logger.info(*args)[source]

Write the sequence of args, with no separators, to the console and output files (if you’ve configured an output file). Using the INFO level.

Parameters

args – log the arguments

Return type

None

stable_baselines3.common.logger.log(*args, level=20)[source]

Write the sequence of args, with no separators, to the console and output files (if you’ve configured an output file).

level: int. (see logger.py docs) If the global logger level is higher than

the level argument here, don’t print to stdout.

Parameters
  • args – log the arguments

  • level (int) – the logging level (can be DEBUG=10, INFO=20, WARN=30, ERROR=40, DISABLED=50)

Return type

None

stable_baselines3.common.logger.make_output_format(_format, log_dir, log_suffix='')[source]

return a logger for the requested format

Parameters
  • _format (str) – the requested format to log to (‘stdout’, ‘log’, ‘json’ or ‘csv’ or ‘tensorboard’)

  • log_dir (str) – the logging directory

  • log_suffix (str) – the suffix for the log file

Return type

KVWriter

Returns

the logger

stable_baselines3.common.logger.read_csv(filename)[source]

read a csv file using pandas

Parameters

filename (str) – the file path to read

Return type

DataFrame

Returns

the data in the csv

stable_baselines3.common.logger.read_json(filename)[source]

read a json file using pandas

Parameters

filename (str) – the file path to read

Return type

DataFrame

Returns

the data in the json

stable_baselines3.common.logger.record(key, value, exclude=None)[source]

Log a value of some diagnostic Call this once for each diagnostic quantity, each iteration If called many times, last value will be used.

Parameters
  • key (str) – save to log this key

  • value (Any) – save to log this value

  • exclude (Union[str, Tuple[str, …], None]) – outputs to be excluded

Return type

None

stable_baselines3.common.logger.record_dict(key_values)[source]

Log a dictionary of key-value pairs.

Parameters

key_values (Dict[str, Any]) – the list of keys and values to save to log

Return type

None

stable_baselines3.common.logger.record_mean(key, value, exclude=None)[source]

The same as record(), but if called many times, values averaged.

Parameters
  • key (str) – save to log this key

  • value (Union[int, float]) – save to log this value

  • exclude (Union[str, Tuple[str, …], None]) – outputs to be excluded

Return type

None

stable_baselines3.common.logger.record_tabular(key, value, exclude=None)

Log a value of some diagnostic Call this once for each diagnostic quantity, each iteration If called many times, last value will be used.

Parameters
  • key (str) – save to log this key

  • value (Any) – save to log this value

  • exclude (Union[str, Tuple[str, …], None]) – outputs to be excluded

Return type

None

stable_baselines3.common.logger.reset()[source]

reset the current logger

Return type

None

stable_baselines3.common.logger.set_level(level)[source]

Set logging threshold on current logger.

Parameters

level (int) – the logging level (can be DEBUG=10, INFO=20, WARN=30, ERROR=40, DISABLED=50)

Return type

None

stable_baselines3.common.logger.warn(*args)[source]

Write the sequence of args, with no separators, to the console and output files (if you’ve configured an output file). Using the WARN level.

Parameters

args – log the arguments

Return type

None