chainer.training.StandardUpdater¶
-
class
chainer.training.
StandardUpdater
(iterator, optimizer, converter=<function concat_examples>, device=None, loss_func=None)[source]¶ 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 theupdate_core()
method. Each batch is converted to input arrays byconcat_examples()
by default, which can also be manually set byconverter
argument.Parameters: - 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
'main'
. - 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
'main'
. - converter – Converter function to build input arrays. Each batch
extracted by the main iterator and the
device
option are passed to this function.concat_examples()
is used by default. - device – Device to which the training data is sent. Negative value indicates the host memory (CPU).
- loss_func – Loss function. The target link of the main optimizer is used by default.
Variables: - converter – Converter function.
- loss_func – Loss function. If it is
None
, the target link of the main optimizer is used instead. - device – Device to which the training data is sent.
- iteration – Current number of completed updates.
Methods
-
connect_trainer
(trainer)[source]¶ 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.Parameters: trainer (Trainer) – Trainer object to which the updater is registered.
-
finalize
()[source]¶ 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.
-
get_all_optimizers
()[source]¶ Gets a dictionary of all optimizers for this updater.
Returns: Dictionary that maps names to optimizers. Return type: dict
-
get_iterator
(name)[source]¶ Gets the dataset iterator of given name.
Parameters: name (str) – Name of the dataset iterator. Returns: Corresponding dataset iterator. Return type: Iterator
-
get_optimizer
(name)[source]¶ Gets the optimizer of given name.
Parameters: name (str) – Name of the optimizer. Returns: Corresponding optimizer. Return type: Optimizer
-
update
()[source]¶ 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.
Attributes
-
epoch
¶
-
epoch_detail
¶
-
is_new_epoch
¶
-
previous_epoch_detail
¶
- 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