Shortcuts

PreciseBNHook

class mmcls.core.PreciseBNHook(num_samples: int = 8192, interval: int = 1)[source]

Precise BN hook.

Recompute and update the batch norm stats to make them more precise. During training both BN stats and the weight are changing after every iteration, so the running average can not precisely reflect the actual stats of the current model.

With this hook, the BN stats are recomputed with fixed weights, to make the running average more precise. Specifically, it computes the true average of per-batch mean/variance instead of the running average. See Sec. 3 of the paper Rethinking Batch in BatchNorm <https://arxiv.org/abs/2105.07576> for details.

This hook will update BN stats, so it should be executed before CheckpointHook and EMAHook, generally set its priority to “ABOVE_NORMAL”.

Parameters
  • num_samples (int) – The number of samples to update the bn stats. Defaults to 8192.

  • interval (int) – Perform precise bn interval. Defaults to 1.

after_train_epoch(runner: mmcv.runner.epoch_based_runner.EpochBasedRunner) None[source]

Calculate prcise BN and broadcast BN stats across GPUs.

Parameters

(obj (runner) – EpochBasedRunner): runner object.

Read the Docs v: latest
Versions
master
latest
1.x
dev-1.x
Downloads
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.