group_norm

paddle.static.nn. group_norm ( input, groups, epsilon=1e-05, param_attr=None, bias_attr=None, act=None, data_layout='NCHW', name=None ) [source]

Group Normalization Layer

Refer to Group Normalization .

Parameters
  • input (Tensor) – Tensor with dimension greater than 1, the data type is float32 or float64.

  • groups (int) – The number of groups that divided from channels, the data type is int32.

  • epsilon (float, optional) – The small value added to the variance to prevent division by zero, the data type is float32. Default: 1e-05.

  • param_attr (ParamAttr|bool, optional) – ParamAttr object that specifies weight parameter attribute. If a bool type, only False is supported, which means there is no weight parameter. Default: None, the default weight parameter attribute is used. For more information, please refer to ParamAttr .

  • bias_attr (ParamAttr|bool, optional) – ParamAttr object that specifies bias parameter attribute. If a bool type, only False is supported, which means there is no bias parameter. Default: None, the default bias parameter attribute is used. For more information, please refer to ParamAttr .

  • act (str, optional) – Activation to be applied to the output of group normalization.

  • data_layout (str, optional) – Specify the data format of the input, and the data format of the output will be consistent with that of the input. An optional string from: “NCHW”, “NHWC”. The default is “NCHW”. When it is “NCHW”, the data is stored in the order of: [batch_size, input_channels, *].

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name .

Returns

A Tensor has same data type and data format with input.

Return type

Tensor

Examples

>>> import paddle
>>> paddle.enable_static()

>>> data = paddle.static.data(name='data', shape=[2, 8, 32, 32], dtype='float32')
>>> x = paddle.static.nn.group_norm(input=data, groups=4)
>>> print(x.shape)
(2, 8, 32, 32)