pytorch_pfn_extras.handler.Logic¶
- class pytorch_pfn_extras.handler.Logic(model_name='main', options=None)¶
- Parameters
model_name (str) –
options (Optional[Dict[str, Any]]) –
- Return type
None
- __init__(model_name='main', options=None)¶
A set of methods that defines the training logic.
- Parameters
model_name (str) – Name of the model. Default is
'main'
.options (dict, optional) –
The configuration options.
'backward_outputs'
(list of str):A list of names of outputs that require compution of the gradient.
'autocast'
(bool):If
True
,torch.cuda.amp.autocast
is enabled. Default isFalse
.
'grad_scaler'
(torch.cuda.amp.GradScaler):A gradient scaler that outputs are applied to.
- Return type
None
Methods
__init__
([model_name, options])A set of methods that defines the training logic.
consume_options
(options)A method to update options of Logic.
eval_step
(models, batch_idx, batch)A method for an evaluation step.
train_epoch_begin
(models, epoch, loader)A method called when starting a new epoch of training.
train_epoch_end
(models, epoch)A method called when completing an epoch of training.
train_step
(models, optimizers, batch_idx, batch)A method invokes the model forward and backward passes.
train_step_optimizers
(models, optimizers, …)A method in charge of stepping the provided optimizers.
train_validation_begin
(models)A method called when starting a validation.
train_validation_end
(models)A method called when the validation completes.