recorder¶
Recorder
can record statistics in any module as long as the module follows specific protocol.
Class¶
BaseRecorder¶
- class gedml.recorder.base_recorder.BaseRecorder(project_name='test', root='./', group_name='main', hint_if_exist=True, delete_old_folder=True, is_resume=False, use_wandb=True, initiate_create=True)[source]¶
Bases:
object
Recorder can search and save two forms of information:
Attributions of module. If the module is inherited from
WithRecorder
or the module maintain a to-record list named ‘to_record_list’.Dictionary with specific format:
{ table_name: item_name: value ... }
- Parameters
root (str) – Path where to save the statistics and checkpoint.
hint_if_exist (bool) – Whether to hint if the folder is existed (in case that user delete the folder by mistake)
delete_old_folder (bool) – Whether to delete the old folder if the folder is existed.
- get_data(*args, **kwargs)[source]¶
Extract the information from a module.
- Parameters
data (dict or obj) – Dictionary of obj with TO_RECORD_LIST attribute.
name (str) – Specific name.
- Returns
(dict, int)
output_dict (dict): information dictionary to be saved.
step (int): step counted by
recorder
.
- Return type
tuple
- load_models(*args, **kwargs)[source]¶
Load models.
- Parameters
obj (module) – Modules with TO_SAVE_LIST.
step (int) – Step (or epoch).
device (device) – The computing device to load.
- save_models(*args, **kwargs)[source]¶
Save models.
- Parameters
obj (module) – Modules with TO_SAVE_LIST.
step (int) – Step (or epoch)
best (bool) – Whether to be the best checkpoint.
delete_old (bool) – Whether to delete the old checkpoint.
- search_best_epoch(table_name, primary_key, maximum=True)[source]¶
Search best epoch according given evaluation indicator.
- Parameters
table_name (str) – The csv file.
primary_key (str) – The primary_key to be searched.
maximum (bool) – Whether to regard the maximum to be the best.
- Returns
(best step, best metric)
- Return type
tuple