Skip to content

Callbacks

VAE.callbacks

Collection of callbacks for model training.

VAE.callbacks.ModelCheckpoint

ModelCheckpoint(filepath, period=1, **kwargs)

Bases: ModelCheckpoint

Callback to save the Keras model or model weights at some frequency.

Prevents deprecation warning in super class when period is used.

Parameters:

  • period (int, default: 1 ) –

    Number of epochs between checkpoints.

  • **kwargs

    Additional keyword arguments to be passed to keras.callbacks.ModelCheckpoint.

Source code in VAE/callbacks.py
21
22
23
def __init__(self, filepath: str, period: int = 1, **kwargs):
    super().__init__(filepath, **kwargs)
    self.period = period

VAE.callbacks.Evaluate

Evaluate(x=None, y=None, batch_size=None, verbose=0, sample_weight=None, prefix='val2_', **kwargs)

Bases: Callback

Callback to evaluate the model.

This callbacks evaluates the model on the given data at the end of each epoch. For a detailed description of the input and target data see the Keras documentation for :func:keras.Model.evaluate.

With this callback, further validation datasets can be evaluated during training. The prefix is used to identify the metrics in the logs and should be unique for each validation dataset. The prefix cannot be empty of val_. This would cause training metrics to be overwritten.

Parameters:

  • x

    Input data.

  • y

    Target data.

  • batch_size (int, default: None ) –

    Number of samples per batch.

  • verbose (int, default: 0 ) –

    Verbosity mode.

  • sample_weight

    Sample weights.

  • prefix (str, default: 'val2_' ) –

    Prefix for the metric names. Defaults to 'val2_'.

  • **kwargs

    Additional keyword arguments to be passed to keras.callbacks.Callback.

Raises:

  • ValueError

    If the prefix is empty or val_.

Source code in VAE/callbacks.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def __init__(self,
             x=None,
             y=None,
             batch_size: int = None,
             verbose: int = 0,
             sample_weight=None,
             prefix: str = 'val2_',
             **kwargs):
    self.x = x
    self.y = y
    self.batch_size = batch_size
    self.verbose = verbose
    self.sample_weight = sample_weight
    self.prefix = prefix
    if prefix in {None, '', 'val_'}:
        raise ValueError('prefix cannot be empty or "val_". This will cause the metrics to be overwritten.')

    super().__init__(**kwargs)