Training Tools

Chainer provides a standard implementation of the training loops under the module. It is built on top of many other core features of Chainer, including Variable and Function, Link/Chain/ChainList, Optimizer, Dataset, and Reporter/Summary. Compared to the training loop abstraction of other machine learning tool kits, Chainer’s training framework aims at maximal flexibility, while keeps the simplicity for the typical usages. Most components are pluggable, and users can overwrite the definition.

The core of the training loop abstraction is Trainer, which implements the training loop itself. The training loop consists of two parts: one is Updater, which actually updates the parameters to train, and the other is Extension for arbitrary functionalities other than the parameter update.

Updater and some extensions use chainer.dataset and Iterator to scan the datasets and load mini-batches. The trainer also uses Reporter to collect the observed values, and some extensions use DictSummary to accumulate them and computes the statistics.

You can find many examples for the usage of this training utilities from the official examples. You can also search the extension implementations from Extensions.

Trainer The standard training loop in Chainer.

Updaters Interface of updater objects for trainers. Standard implementation of Updater. Implementation of a parallel GPU Updater. Implementation of a multiprocess parallel GPU Updater.


An extension is a callable object that can perform arbitrary actions during the training loop. Extensions can be registered to Trainer by using Trainer.extend() method, and they are invoked when the Trigger condition is satisfied.

In addition to the built-in extensions listed below, you can define your own extension by implementing Extension or using the make_extension() decorator. See Trainer Extensions for details.

Common Base class of trainer extensions. Decorator to make given functions into trainer extensions.

Evaluation and Metrics Collection

These extensions provide features to collect additional metrics. The typical use case is to use Evaluator to perform evaluation with a validation dataset to compute validation loss/accuracy. Trainer extension to evaluate models on a validation set. Calculates micro-average ratio. Trainer extension to raise RuntimeError if parameters contain NaN or Inf. Trainer extension to report parameter statistics. Returns a trainer extension to record the learning rate. Returns a trainer extension to continuously record a value.

Optimizer Behavior Control

These extensions provide features to adjust optimizer behavior. The typical use case is to change the learning rate of the optimizer over time. Trainer extension to exponentially shift an optimizer attribute. Trainer extension to change an optimizer attribute linearly. Trainer extension to polynomially shift an optimizer attribute.


These extensions provide features to perform reporting of metrics and various statistics to the console or files. Trainer extension to print the accumulated results. Trainer extension to print a progress bar and recent training status. Trainer extension to output the accumulated results to a log file. Trainer extension to output plots. Trainer extension to plot statistics for Variables. Returns a trainer extension to dump a computational graph.


These extensions provide features to take snapshots of models. Returns a trainer extension to take snapshots of the trainer. Returns a trainer extension to take snapshots of a given object.


A trigger is a callable object to decide when to process some specific event within the training loop. It takes a Trainer object as the argument, and returns True if some event should be fired.

It is mainly used to determine when to call an extension. It is also used to determine when to quit the training loop. Gets a trigger object. Trigger invoked when specific value becomes best. Trigger for Early Stopping Trigger based on a fixed interval. Trigger invoked at specified point(s) of iterations or epochs. Trigger invoked when specific value becomes maximum. Trigger invoked when specific value becomes minimum. Trigger based on a fixed time interval.