OmniSafe Logger#
|
Implementation of the Logger. |
Logger#
Documentation
- class omnisafe.common.logger.Logger(output_dir, exp_name, output_fname='progress.csv', verbose=True, seed=0, use_tensorboard=True, use_wandb=False, config=None, models=None)[source]#
Implementation of the Logger.
A logger to record the training process. It can record the training process to a file and print it to the console. It can also record the training process to tensorboard.
The logger can record the following data:
---------------------------------------------- | Name | Value | ---------------------------------------------- | Train/Epoch | 25 | | Metrics/EpCost | 24.56 | | Metrics/EpLen | 1000 | | Metrics/EpRet | 13.24 | | Metrics/EpStd | 0.12 | ----------------------------------------------
Initialize the logger.
- Parameters:
output_dir (
str
) – The directory to save the log file.exp_name (
str
) – The name of the experiment.output_fname (
str
) – The name of the log file.verbose (
bool
) – Whether to print the log to the console.seed (
int
) – The random seed.use_tensorboard (
bool
) – Whether to use tensorboard.use_wandb (
bool
) – Whether to use wandb.config (
Optional
[Config
]) – The config of the experiment.models (
Optional
[List
[Module
]]) – The models to be saved.
- __init__(output_dir, exp_name, output_fname='progress.csv', verbose=True, seed=0, use_tensorboard=True, use_wandb=False, config=None, models=None)[source]#
Initialize the logger.
- Parameters:
output_dir (
str
) – The directory to save the log file.exp_name (
str
) – The name of the experiment.output_fname (
str
) – The name of the log file.verbose (
bool
) – Whether to print the log to the console.seed (
int
) – The random seed.use_tensorboard (
bool
) – Whether to use tensorboard.use_wandb (
bool
) – Whether to use wandb.config (
Optional
[Config
]) – The config of the experiment.models (
Optional
[List
[Module
]]) – The models to be saved.
- _update_current_row()[source]#
Update the current row.
Update the current row with the data stored in the logger.
- Return type:
None
- property current_epoch: int#
Return the current epoch.
- dump_tabular()[source]#
Dump the tabular data to the console and the file.
The dumped data will be separated by the following steps: :rtype:
None
Hint
If the key is registered with window_length, the data will be averaged in the window.
Write the data to the csv file.
Write the data to the tensorboard.
Update the progress logger.
- get_stats(key, min_and_max=False)[source]#
Get the statistics of the key.
- Parameters:
key (str) – The key to be registered.
min_and_max (bool) – Whether to record the min and max value of the key.
- Return type:
Tuple
[Union
[int
,float
],...
]
- log(msg, color='green', bold=False)[source]#
Log the message to the console and the file.
- Parameters:
msg (str) – The message to be logged.
color (int) – The color of the message.
bold (bool) – Whether to use bold font.
- Return type:
None
- register_key(key, window_length=None, min_and_max=False, delta=False)[source]#
Register a key to the logger.
The logger can record the following data:
---------------------------------------------------- | Name | Value | ---------------------------------------------------- | Train/Epoch | 25 | | Metrics/EpCost/Min | 22.38 | | Metrics/EpCost/Max | 25.48 | | Metrics/EpCost/Mean | 23.93 | ----------------------------------------------------
- Parameters:
key (str) – The key to be registered.
window_length (int) – The window length for the key, if window_length is None, the key will be averaged in epoch.
min_and_max (bool) – Whether to record the min and max value of the key.
delta (bool) – Whether to record the delta value of the key.
- Return type:
None
- save_config(config)[source]#
Save the configuration to the log directory.
- Parameters:
config (Config) – The configuration to be saved.
- Return type:
None
- setup_torch_saver(what_to_save)[source]#
Setup the torch saver.
- Parameters:
what_to_save (dict) – The dict of the things to be saved.
- Return type:
None