This module tries to provided a class wrapper to mimic the TensorFlow API of tensorflow.keras.Model. It is intended to simplify the training of a model through methods like compile, fit and evaluate which allow the user to define custom loss functions, optimizers, evaluation metrics, train a model and evaluate it. Currently it is used internally to test the functionalities for the Pytorch backend. To be discussed if the module will be exposed to the user in future versions.
- class alibi.models.pytorch.model.Model(*args: Any, **kwargs: Any)
- compile(optimizer, loss, loss_weights=None, metrics=None)
Compiles a model by setting the optimizer and the loss functions, loss weights and metrics to monitor the training of the model..
Optimizer) – Optimizer to be used.
- compute_loss(y_pred, y_true)
Computes the loss given the prediction labels and the true labels.
- Return type
A tuple consisting of the total loss computed as a weighted sum of individual losses and a dictionary of individual losses used of logging.
- compute_metrics(y_pred, y_true)
Computes the metrics given the prediction labels and the true labels.
Evaluation function. The function reports the evaluation metrics used for monitoring the training loop.
- fit(trainloader, epochs)
Fit method. Equivalent of a training loop.
- test_step(x, y)
Performs a test step.
- train_step(x, y)
Performs a train step.