scalarstop._keras_callbacks

Private Keras callbacks that make KerasModel work.

Module Contents

Classes

BatchLoggingCallback

A Keras callback to handle some of the bookkeeping.

EpochCallback

A Keras callback to handle some of the bookkeeping.

Functions

logs_as_floats(logs: Mapping[str, Any]) → Dict[str, float]

Convert Keras metric log values to floats.

logs_as_floats(logs: Mapping[str, Any]) Dict[str, float]

Convert Keras metric log values to floats.

class BatchLoggingCallback(*, scalarstop_model, logger)

Bases: tf.keras.callbacks.Callback

A Keras callback to handle some of the bookkeeping.

on_train_batch_end(self, batch: int, logs: Dict[str, Any]) None

Enable issuing log messages at the end of every batch.

class EpochCallback(*, scalarstop_model, logger, steps_per_epoch: Optional[int] = None, validation_steps_per_epoch: Optional[int] = None, models_directory: Optional[str] = None, train_store=None, log_epochs: bool = False)

Bases: tf.keras.callbacks.Callback

A Keras callback to handle some of the bookkeeping.

on_epoch_end(self, epoch: int, logs: Dict[str, Any]) None
Enable various tasks at the end of every epoch, such as:
  • saving the model to the filesystem.

  • saving epoch metrics to the TrainStore.

  • logging epoch metrics to a Python logger.