EMAHook — mmengine 0.10.7 documentation (original) (raw)

class mmengine.hooks.EMAHook(ema_type='ExponentialMovingAverage', strict_load=False, begin_iter=0, begin_epoch=0, **kwargs)[source]

A Hook to apply Exponential Moving Average (EMA) on the model during training.

Note

Parameters:

after_load_checkpoint(runner, checkpoint)[source]

Resume ema parameters from checkpoint.

Parameters:

Return type:

None

after_test_epoch(runner, metrics=None)[source]

We recover source model’s parameter from ema model after test.

Parameters:

Return type:

None

after_train_iter(runner, batch_idx, data_batch=None, outputs=None)[source]

Update ema parameter.

Parameters:

Return type:

None

after_val_epoch(runner, metrics=None)[source]

We recover source model’s parameter from ema model after validation.

Parameters:

Return type:

None

before_run(runner)[source]

Create an ema copy of the model.

Parameters:

runner (Runner) – The runner of the training process.

Return type:

None

before_save_checkpoint(runner, checkpoint)[source]

Save ema parameters to checkpoint.

Parameters:

Return type:

None

before_test_epoch(runner)[source]

We load parameter values from ema model to source model before test.

Parameters:

runner (Runner) – The runner of the training process.

Return type:

None

before_train(runner)[source]

Check the begin_epoch/iter is smaller than max_epochs/iters.

Parameters:

runner (Runner) – The runner of the training process.

Return type:

None

before_val_epoch(runner)[source]

We load parameter values from ema model to source model before validation.

Parameters:

runner (Runner) – The runner of the training process.

Return type:

None