Optimizer Settings


To define the update algorithm, set the parameter optimizer to a dictionary and define the type by setting class. All available optimizers and their parameters can be found here. Setting the learning rate should not set in the dict, but rather separately. If no updater is specified, plain SGD is used.

The learning rate control scheme is set with learning_rate_control, and many possible settings are available for the different control schemes. For the default values have a look at LearningRateControl.py.


RETURNN will override the optimizer epsilon with 1e-16 if not specified otherwise, this can lead to unwanted behaviour when assuming a default epsilon of e.g. 1e-8 for Adam.

An integer specifying the number of updates to stack the gradient, called “gradient accumulation”.
Specifiy a gradient clipping threshold.
Apply a (gaussian?) noise to the gradient with given deviation (variance? stddev?)
Specifies the global learning rate
A list of learning rates that defines the learning rate for each epoch from the beginning. Can be used for learning-rate warmup.

This defines which type of learning rate control mechanism is used. Possible values are:

  • constant for a constant learning rate which is never modified
  • newbob_abs for a scheduling based on absolute improvement
  • newbob_rel for a scheduling based on relative improvement
  • newbob_multi_epoch for a scheduling based on relative improvement averaged over multiple epochs

Please also look at setting values with the newbob prefix for further customization

A str to define which score or error is used to control the learning rate reduction. Per default, Returnn will use dev_score_output. A typical choice would be dev_score_LAYERNAME or dev_error_LAYERNAME. Can be set to None to disable learning rate control.
The number of epochs after the last update that the learning rate is kept constant.
If true, the relative error is scaled with the ratio of the default learning rate divided by the current learning rate. Can be used with newbob_rel and newbob_multi_epoch.
A path to a file storing the learning rate for each epoch. Despite the name, also stores scores and errors.
Specifies the minimum learning rate.
This is the absolute improvement that has to be achieved in order to _not_ reduce the learning rate. Can be used with newbob_abs. The value can be positive or negative.
The scaling factor for the learning rate when a reduction is applied. This parameter is available for all newbob variants.
The number of epochs the improvement is averaged over.
The number of steps after which the learning rate is updated. This is set equal to newbob_multi_num_epochs when not specified.
This is the relative improvement that has to be achieved in order to _not_ reduce the learning rate. Can be used with newbob_rel and newbob_multi_epoch. The value can be positive or negative.
A dictionary with a class entry for the optimizer. Other keys are passed as parameters to the constructor of the optimizer class.
If true the relative error is computed by dividing the error difference by the old error value instead of the current error value.
If true, use the learning rate control scheme also during pre-training.