dcase_util.tfkeras.StasherCallback

class dcase_util.tfkeras.StasherCallback(epochs=None, manual_update=False, monitor='val_loss', mode='auto', period=1, initial_delay=10, save_weights=False, file_path=None, **kwargs)[source]

Keras callback to monitor training process and store best model. Implements Keras Callback API.

This callback is very similar to standard ModelCheckpoint Keras callback, however it adds support for external metrics (metrics calculated outside Keras training process).

Constructor

Parameters
epochsint

Total amount of epochs Default value None

manual_updatebool

Manually update callback, use this to when injecting external metrics Default value False

monitorstr

Metric to monitor Default value ‘val_loss’

modestr

Which way metric is interpreted, values {auto, min, max} Default value ‘auto’

periodint

Save only after every Nth epoch Default value 1

initial_delayint

Amount of epochs to wait at the beginning before quantity is monitored. Default value 10

save_weightsbool

Save weight to the disk Default value False

file_pathstr

File name for model weight Default value None

__init__(epochs=None, manual_update=False, monitor='val_loss', mode='auto', period=1, initial_delay=10, save_weights=False, file_path=None, **kwargs)[source]

Constructor

Parameters
epochsint

Total amount of epochs Default value None

manual_updatebool

Manually update callback, use this to when injecting external metrics Default value False

monitorstr

Metric to monitor Default value ‘val_loss’

modestr

Which way metric is interpreted, values {auto, min, max} Default value ‘auto’

periodint

Save only after every Nth epoch Default value 1

initial_delayint

Amount of epochs to wait at the beginning before quantity is monitored. Default value 10

save_weightsbool

Save weight to the disk Default value False

file_pathstr

File name for model weight Default value None

Methods

__init__([epochs, manual_update, monitor, ...])

Constructor

add_external_metric(metric_label)

get_best()

Return best model seen

get_operator(metric)

log()

Print information about the best model into logging interface

on_epoch_begin(epoch[, logs])

on_epoch_end(epoch[, logs])

on_predict_batch_begin(batch[, logs])

on_predict_batch_end(batch[, logs])

on_predict_begin([logs])

on_predict_end([logs])

on_test_batch_begin(batch[, logs])

on_test_batch_end(batch[, logs])

on_test_begin([logs])

on_test_end([logs])

on_train_batch_begin(batch[, logs])

on_train_batch_end(batch[, logs])

on_train_begin([logs])

on_train_end([logs])

set_external_metric_value(metric_label, ...)

Add external metric value

set_model(model)

set_params(params)

show([mode, indent])

Print information about the best model

to_html([indent])

Get information in a HTML formatted string

to_string([ui, indent])

Get information in a string

update()

Attributes

logger