bob.ip.binseg.engine.trainer¶
Functions
|
Fits an FCN model using supervised learning and save it to disk. |
|
Context manager to turn ON/OFF model evaluation |
- bob.ip.binseg.engine.trainer.torch_evaluation(model)[source]¶
Context manager to turn ON/OFF model evaluation
This context manager will turn evaluation mode ON on entry and turn it OFF when exiting the
with
statement block.- Parameters
model (
torch.nn.Module
) – Network (e.g. driu, hed, unet)- Yields
model (
torch.nn.Module
) – Network (e.g. driu, hed, unet)
- bob.ip.binseg.engine.trainer.run(model, data_loader, valid_loader, optimizer, criterion, scheduler, checkpointer, checkpoint_period, device, arguments, output_folder)[source]¶
Fits an FCN model using supervised learning and save it to disk.
This method supports periodic checkpointing and the output of a CSV-formatted log with the evolution of some figures during training.
- Parameters
model (
torch.nn.Module
) – Network (e.g. driu, hed, unet)data_loader (
torch.utils.data.DataLoader
) – To be used to train the modelvalid_loader (
torch.utils.data.DataLoader
) – To be used to validate the model and enable automatic checkpointing. If set toNone
, then do not validate it.optimizer (
torch.optim
) –criterion (
torch.nn.modules.loss._Loss
) – loss functionscheduler (
torch.optim
) – learning rate schedulercheckpointer (
bob.ip.binseg.utils.checkpointer.Checkpointer
) – checkpointer implementationcheckpoint_period (int) – save a checkpoint every
n
epochs. If set to0
(zero), then do not save intermediary checkpointsdevice (
torch.device
) – device to usearguments (dict) – start and end epochs
output_folder (str) – output path