Browse Source

docs(mge/module): add note about definition of momentum in BatchNorm

GitOrigin-RevId: 30a9aec20f
release-1.7
Megvii Engine Team 3 years ago
parent
commit
8d507cc39d
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      imperative/python/megengine/module/batchnorm.py

+ 11
- 0
imperative/python/megengine/module/batchnorm.py View File

@@ -280,6 +280,17 @@ class BatchNorm2d(_BatchNorm):
statistics on `(N, H, W)` slices, it's common terminology to call this statistics on `(N, H, W)` slices, it's common terminology to call this
Spatial Batch Normalization. Spatial Batch Normalization.


.. note::

The update formula for ``running_mean`` and ``running_var`` (taking ``running_mean`` as an example) is

.. math::

\textrm{running_mean} = \textrm{momentum} \times \textrm{running_mean} + (1 - \textrm{momentum}) \times \textrm{batch_mean}

which could be defined differently in other frameworks. Most notably, ``momentum`` of 0.1 in PyTorch
is equivalent to ``mementum`` of 0.9 here.

Args: Args:
num_features: usually :math:`C` from an input of shape num_features: usually :math:`C` from an input of shape
:math:`(N, C, H, W)` or the highest ranked dimension of an input :math:`(N, C, H, W)` or the highest ranked dimension of an input


Loading…
Cancel
Save