group_norm¶
- api_attr
declarative programming (static graph)
-
paddle.fluid.layers.
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 (Variable) – 4-D Tensor, 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, input_height, input_width].
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 4-D Tensor has same data type and data format with input.
- Return type
Variable
- Raises
ValueError
– If data_layout is neither ‘NCHW’ nor ‘NHWC’.ValueError
– If groups is greater than the number of input channels.ValueError
– If groups is less than 1.ShapeError
– If the param_attr(Scale) is not 1-D Tensor.ShapeError
– If the param_attr(Scale)’s first dimension size is not equal to the input channels.ShapeError
– If the bias_attr(Bias) is not 1-D Tensor.ShapeError
– If the bias_attr(Bias)’s first dimension size is not equal to the input channels.
Examples
import paddle.fluid as fluid data = fluid.data(name='data', shape=[None, 8, 32, 32], dtype='float32') x = fluid.layers.group_norm(input=data, groups=4)