GroupNorm¶
- class GroupNorm(num_groups, num_channels, eps=1e-05, affine=True, **kwargs)[源代码]¶
Applies Group Normalization over a mini-batch of inputs Refer to Group Normalization
\[y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta\]The mean and standard-deviation are calculated separately over the each group. \(\\gamma\) and \(\\beta\) are learnable affine transform parameters of attr:num_channels if
affine
isTrue
.- 参数
- 形状:
Input: \((N, C, H, W)\) (now only support NCHW format tensor)
Output: \((N, C, H, W)\) (same shape as input)
实际案例
>>> import numpy as np >>> inp = Tensor(np.arange(2 * 3 * 4 * 4).astype(np.float32).reshape(2, 3, 4, 4)) >>> m = M.GroupNorm(3, 3) >>> out = m(inp) >>> out.numpy().shape (2, 3, 4, 4)