SyncBatchNorm

class dragon.vm.torch.nn.SyncBatchNorm(
  num_features,
  eps=1e-05,
  momentum=0.1,
  affine=True,
  track_running_stats=True,
  process_group=None
)[source]

Apply the sync batch normalization over input. [Ioffe & Szegedy, 2015].

The normalization is defined as:

\[y = \frac{x - \mathrm{E}[x]}{\sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta \]

The moving average of stats are calculated as:

\[x_{moving} \leftarrow (1 - momentum) * x_{moving} + momentum * x_{stat} \]

Additionally, you can specify process_group to perform synchronization.

If not, value returning from dragon.distributed.get_group(...) will be used.

__init__

SyncBatchNorm.__init__(
  num_features,
  eps=1e-05,
  momentum=0.1,
  affine=True,
  track_running_stats=True,
  process_group=None
)[source]

Create a SyncBatchNorm module.

Parameters:
  • num_features (int) – The number of channels.
  • eps (float, optional, default=1e-5) – The epsilon value.
  • momentum (float, optional, default=0.1) – The momentum of moving average.
  • affine (bool, optional, default=True) – True to apply a affine transformation.
  • track_running_stats (bool, optional, default=True) – True to using stats when switching to eval.
  • process_group (ProcessGroup, optional) – The group for communication.