- class chainer.training.updaters.StandardUpdater(iterator, optimizer, converter=convert.concat_examples, device=None, loss_func=None, loss_scale=None, auto_new_epoch=True, *, input_device=None)¶
Standard implementation of Updater.
This is the standard implementation of
Updater. It accepts one or more training datasets and one or more optimizers. The default update routine assumes that there is only one training dataset and one optimizer. Users can override this update routine by inheriting this class and overriding the
update_core()method. Each batch is converted to input arrays by
chainer.dataset.concat_examples()by default, which can also be manually set by
iterator – Dataset iterator for the training dataset. It can also be a dictionary that maps strings to iterators. If this is just an iterator, then the iterator is registered by the name
optimizer – Optimizer to update parameters. It can also be a dictionary that maps strings to optimizers. If this is just an optimizer, then the optimizer is registered by the name
converter – Converter function to build input arrays. Each batch extracted by the main iterator and the
deviceoption are passed to this function.
chainer.dataset.concat_examples()is used by default.
device (device specifier) – Device to which the model is sent. If
None, the device of the model will stay unchanged.
loss_func – Loss function. The target link of the main optimizer is used by default.
loss_scale (float) – Loss scaling factor. Loss scaling is a usefull technique to mitigate vanishing gradient issue that tends to happen when low precision data type like float16 is used during training. If you set loss scaling factor, gradients of loss values are to be multiplied by the factor before backprop starts. The factor is propagated to whole gradients in a computational graph along the backprop. The gradients of parameters are divided by the factor just before the parameters are to be updated.
input_device (device specifier) – Device to which the training data is sent. If
input_deviceis omitted, it will match the
~StandardUpdater.converter – Converter function.
~StandardUpdater.loss_func – Loss function. If it is
None, the target link of the main optimizer is used instead.
~StandardUpdater.device – Device to which the model is sent.
~StandardUpdater.input_device – Device to which the training data is sent.
~StandardUpdater.iteration – Current number of completed updates.
~StandardUpdater.auto_new_epoch – If
new_epoch()is automatically called by
update_core(). In this case, the
use_auto_new_epochattribute of each optimizer is also set to
update_core()is overridden, the implementation should correctly call
new_epoch()of each optimizer.
Connects the updater to the trainer that will call it.
The typical usage of this method is to register additional links to the reporter of the trainer. This method is called at the end of the initialization of
Trainer. The default implementation does nothing.
trainer (Trainer) – Trainer object to which the updater is registered.
Finalizes the updater object.
This method calls the finalize method of each iterator that this updater has. It is called at the end of training loops.
Gets a dictionary of all optimizers for this updater.
Dictionary that maps names to optimizers.
- Return type
Gets the dataset iterator of given name.
Gets the optimizer of given name.
Serializes the current state of the updater object.
Updates the parameters of the target model.
This method implements an update formula for the training task, including data loading, forward/backward computations, and actual updates of parameters.
This method is called once at each iteration of the training loop.
- __eq__(value, /)¶
- __ne__(value, /)¶
- __lt__(value, /)¶
- __le__(value, /)¶
- __gt__(value, /)¶
- __ge__(value, /)¶