alibi_detect.models.trainer module

alibi_detect.models.trainer.trainer(model, loss_fn, X_train, y_train=None, optimizer=tensorflow.keras.optimizers.Adam, loss_fn_kwargs=None, epochs=20, batch_size=64, buffer_size=1024, verbose=True, log_metric=None, callbacks=None)[source]

Train TensorFlow model.

Parameters
  • model (tensorflow.keras.Model) – Model to train.

  • loss_fn (tensorflow.keras.losses) – Loss function used for training.

  • X_train (numpy.ndarray) – Training batch.

  • y_train (Optional[numpy.ndarray]) – Training labels.

  • optimizer (tensorflow.keras.optimizers) – Optimizer used for training.

  • loss_fn_kwargs (Optional[dict]) – Kwargs for loss function.

  • epochs (int) – Number of training epochs.

  • batch_size (int) – Batch size used for training.

  • buffer_size (int) – Maximum number of elements that will be buffered when prefetching.

  • verbose (bool) – Whether to print training progress.

  • log_metric (Optional[Tuple[str, tensorflow.keras.metrics]]) – Additional metrics whose progress will be displayed if verbose equals True.

  • callbacks (Optional[tensorflow.keras.callbacks]) – Callbacks used during training.

Return type

None