Exponential Moving Average (EMA)#

During training, EMA maintains a moving average of the trained parameters. EMA parameters can produce significantly better results and faster convergence for a variety of different domains and models.

EMA is a simple calculation. EMA Weights are pre-initialized with the model weights at the start of training.

Every training update, the EMA weights are updated based on the new model weights.

\[ema_w = ema_w * decay + model_w * (1-decay)\]

Enabling EMA is straightforward. We can pass the additional argument to the experiment manager at runtime.

python examples/asr/asr_ctc/ \
    model.train_ds.manifest_filepath=/path/to/my/train/manifest.json \
    model.validation_ds.manifest_filepath=/path/to/my/validation/manifest.json \
    trainer.devices=2 \
    trainer.accelerator='gpu' \
    trainer.max_epochs=50 \
    exp_manager.ema.enable=True # pass this additional argument to enable EMA

To change the decay rate, pass the additional argument.

python examples/asr/asr_ctc/ \
    exp_manager.ema.enable=True \

We also offer other helpful arguments.




Validate the original weights instead of EMA weights.


Apply EMA every N steps instead of every step.


Offload EMA weights to CPU. May introduce significant slow-downs.