luz.callbacks module¶
Contains callback objects which perform various actions during the training process.
- class ActualVsPredicted(filepath=None)¶
Bases:
luz.callbacks.Callback
Plot actual labels vs. predicted labels.
- Parameters
filepath (
Union
[str
,Path
,None
]) – Path to save plot if not None, by default None.
- batch_ended(output, target, flag, **kwargs)¶
Compute on batch end.
- Parameters
output (
Tensor
) – Output tensor. Shape: \((N,)\)target (
Tensor
) – Target tensor. Shape: \((N,)\)
- Return type
None
- testing_ended(**kwargs)¶
Compute on testing end.
- Return type
None
- testing_started(**kwargs)¶
Compute on testing start.
- Return type
None
- class Callback¶
Bases:
object
- batch_ended(**kwargs)¶
- batch_started(**kwargs)¶
- epoch_ended(**kwargs)¶
- epoch_started(**kwargs)¶
- log(loggers, msg)¶
- Return type
None
- testing_ended(**kwargs)¶
- testing_started(**kwargs)¶
- training_ended(**kwargs)¶
- training_started(**kwargs)¶
- validating_ended(**kwargs)¶
- validating_started(**kwargs)¶
- class LogMetrics(metrics, log_every=1)¶
Bases:
luz.callbacks.Callback
- batch_ended(**kwargs)¶
- epoch_ended(model, epoch, loggers, **kwargs)¶
- epoch_started(**kwargs)¶
- class Loss(print_interval=0.25)¶
Bases:
luz.callbacks.Callback
Calculate running loss throughout each epoch.
- Parameters
print_interval (
Optional
[float
]) – Fraction of epoch after which the running loss is printed, by default 0.25.- Raises
ValueError –
- batch_ended(flag, loader, epoch, loss, ind, loggers, **kwargs)¶
Execute at end of batch.
- Parameters
flag (
Flag
) – Training flag.loader (
DataLoader
) – Data loader.epoch (
int
) – Epoch number.loss (
Tensor
) – Last computed loss.ind (
int
) – Data index.**kwargs – Superfluous kwargs.
- Return type
None
- epoch_started(**kwargs)¶
- Return type
None
- class PlotHistory(show_plot=True, save_filepath=None, reduction='mean')¶
Bases:
luz.callbacks.Callback
- training_ended(train_history, val_history, train_loader, val_loader, **kwargs)¶
- Return type
None
- class Progress(print_interval=0.25, bar_length=30)¶
Bases:
luz.callbacks.Callback
- batch_ended(loader, epoch, flag, ind, loggers, **kwargs)¶
- Return type
None
- epoch_started(loggers, **kwargs)¶
- Return type
None
- testing_ended(loggers, **kwargs)¶
- Return type
None
- testing_started(loggers, **kwargs)¶
- Return type
None
- training_ended(loggers, **kwargs)¶
- Return type
None
- training_started(loggers, **kwargs)¶
- Return type
None
- class Timer¶
Bases:
luz.callbacks.Callback
- epoch_ended(epoch, flag, loggers, **kwargs)¶
- Return type
None
- epoch_started(**kwargs)¶
- Return type
None