Optimizer recovery: the same weight may also move to different next steps

Optimizers with momentum or self-adaptation statistics use more than the current gradient.

• Step by stepCollate in 2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives 2 first fixes

Try to do it after reading

  • Explains why the momentum and the steps need to be restored
  • Distinguishing reasoning weights from training check points

Suggested first

  • Target function to oversee learning
  • Basic training and validation cycle

The weight is the current position. The optimist remembers history

Optimizers with momentum or self-adaptation statistics use more than the current gradient. The restoration of model weights would re-establish an empty optimist, and the next step could be different from before the interruption. This is usually irrelevant for models that merely follow reasoning, but it is a state-of-the-art condition for continuing training.

Description with Simplified Dynamics: v_new = 0.9 v_old+g, w_new = w−0 1 v_new. Sets w = 2, old momentum v = 4, current gradient g =1, normally continues to receive v_new = 4.6, w_new = 1.54; If you forget to restore the momentum, v_old = 0, get w_new = 1.9. The current weight is exactly the same as the gradient, and the differences are all historical.

Adam also has a correction of deviations associated with the first and second steps. Only two of the rules are restored, but step is zero, and it may change the update. The learning rate scheduler and the blending precision scaler, if in a state of training, should also be preserved and restored as an actual interface. The internal state cannot be replaced with the "consequential name of the optimist class".

Parameter relativity cannot be misaligned

Optimizer state corresponds to the correct parameter. Blind loading may result in incompatibility or erroneous mapping after the model structure or the order of the parameter group has changed. When adding layers, freezing strategies or changing weight shapes, it should be clear whether they are strictly restored, partially relocated or intentionally reset the optimizer and the reason for it should be recorded.

Continued training and fine-tuning do not require the same recovery strategy. The fine-tuning, sometimes with a desire to use new optimizers and new learning rates, is an intentional new experiment; But it cannot be described as a complete continuum with recovery before the interruption. The name should reflect the true operation and avoid error in debugging with the expectation of gradual convergence.

The minimum restoration check can save the integrity of a step, the original process is implemented, and the same data is used to implement a step after the new process is loaded, comparing the updated weight and optimizer statistics. The random layer, data sequence and numerical environment are also fixed, otherwise the source of the difference is more than an optimist.

This section uses a general dynamic formula, and the example is not the complete realization of all options in a library. The PyTorch current check point document provides the status saving interface, and the actual parameter semantic text matches the version; 1.54 and 1.9.

Value recovery

import math
v=0.9*4+1
assert math.isclose(2-0.1*v,1.54)
assert math.isclose(2-0.1,1.9)
w = 2, v = 4, g = 1, momentum 0.9, learning rate 0.1, what is the next w?

The new momentum of 4.6 shall be changed to 2-0.46 = 1.54. If the movement is replaced by 1.9.

Are there any errors to fine-tune the new optimiser?

Not necessarily. It could be a reasonable new training phase, but it should be clearly reset rather than claiming a complete return to the original training trajectory.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. PyTorch — Saving and Loading a General Checkpoint
  2. Decoupled Weight Decay Regularization

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.