group_norm

dragon.nn.group_norm(
  inputs,
  axis=- 1,
  group=0,
  epsilon=1e-05,
  **kwargs
)[source]

Apply the group normalization. [Wu & He, 2018].

The normalization is defined as:

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

group could be zero to apply the instance normalization:

gamma, beta = dragon.ones((3,)), dragon.zeros((3,))
x = dragon.constant([[1., 2., 3.], [4., 5., 6.]], dtype=gamma.dtype)
y = dragon.nn.group_norm([x, gamma, beta], group=0)
print(y)  # [[0., 0., 0.], [0., 0., 0.]]
Parameters:
  • inputs (Sequence[dragon.Tensor]) – The tensor x, gamma and beta.
  • axis (int, optional, default=-1) – The channel axis.
  • group (int, optional, default=0) – The group size.
  • epsilon (float, optional, default=1e-5) – The value to \(\epsilon\).
Returns:

dragon.Tensor – The output tensor.