CsvLoggingCallback

class hybrid_learning.concepts.train_eval.callbacks.CsvLoggingCallback(log_dir='.', overwrite='warn')[source]

Bases: Callback

Extract the values stored in matplotlib figures and store them as CSV. Only figures with one axis and one line in the plot are supported. Figure data is saved into a CSV file under log_dir with the name given by to_descriptor() with one column for x-data, one for y-data.

Note

For the file path format see file_path_for() and file_paths_in().

Public Data Attributes:

OTHER_KPI_NAME

The default KPI name for CSV files collecting non-image metric data.

DEFAULT_DESC

A default description to use if no other folder identifier can be determined.

Public Methods:

file_path_for(kpi_name[, run_type, ...])

Given logging specs provide the file path these should be located at.

after_epoch_train(kpi_train[, epoch, ...])

Save figures in the final batch results.

after_epoch_eval(kpi_val[, epoch, ...])

Save figures in the eval epoch results.

from_csv([file_path, kpi_name, run_type, ...])

Read a previously saved pandas.DataFrame.

Inherited from : py: class:Callback

keys()

Collect a list of all supported callback events.

Inherited from : py: class:Mapping

get(k[,d])

keys()

Collect a list of all supported callback events.

items()

values()

Special Methods:

__init__([log_dir, overwrite])

Init.

Inherited from : py: class:Callback

__getitem__(event)

Get the method for the specified event or a pass lambda.

__len__()

Number of mapped events.

__iter__()

Iterate over mapped events.

Inherited from : py: class:Mapping

__getitem__(event)

Get the method for the specified event or a pass lambda.

__contains__(key)

__eq__(other)

Return self==value.

Inherited from : py: class:Sized

__len__()

Number of mapped events.

Inherited from : py: class:Iterable

__iter__()

Iterate over mapped events.

Inherited from : py: class:Container

__contains__(key)


__init__(log_dir='.', overwrite='warn')[source]

Init.

Parameters
after_epoch_eval(kpi_val, epoch=None, log_prefix=None, run=None, run_type='eval', **_)[source]

Save figures in the eval epoch results.

Parameters
after_epoch_train(kpi_train, epoch=None, log_prefix=None, run=None, run_type='train', **_)[source]

Save figures in the final batch results.

Parameters
file_path_for(kpi_name, run_type=None, log_prefix=None, run=None, epoch=None, batch=None, default_desc=None)[source]

Given logging specs provide the file path these should be located at.

Parameters
Return type

str

classmethod file_paths_in(log_dir, use_abs_paths=True)[source]

Given a log_dir return information on saved metrics.

Parameters
  • log_dir (str) – the root logging directory under which metrics were saved

  • use_abs_paths (bool) – whether to specify paths relative to log_dir or absolute

Returns

a DataFrame containing in each row meta information and the relative file path to a saved metric.

Return type

List[Dict[str, str]]

from_csv(file_path=None, kpi_name='other', run_type=None, log_prefix=None, run=None, epoch=None, batch=None)[source]

Read a previously saved pandas.DataFrame. Either give file_path or a combination of the other infos.

Parameters
Return type

DataFrame

DEFAULT_DESC: str = '_'

A default description to use if no other folder identifier can be determined.

OTHER_KPI_NAME: str = 'other'

The default KPI name for CSV files collecting non-image metric data.

__parameters__ = ()
log_dir: str

The root directory under which to store figure data.

overwrite: Union[str, bool]

Whether to overwrite existing files. The following values are treated special:

  • 'warn': overwrite but log a warning if exists

  • 'raise': do not overwrite and raise a FileExistsError if exists