parameters: (input,
                 groups,
                 epsilon=1e-05,
                 param_attr=None,
                 bias_attr=None,
                 act=None,
                 data_layout='NCHW',
                 name=None)
return_statement: return helper.append_activation(group_norm_out)
docstring: :api_attr: Static Graph
  
      **Group Normalization Layer**
  
      Refer to `Group Normalization <https://arxiv.org/abs/1803.08494>`_ .
  
      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 :ref:`api_guide_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 :ref:`api_guide_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 :ref:`api_guide_Name` .
  
      Returns:
          Tensor: A Tensor has same data type and data format with `input`.
  
      Examples:
         .. code-block:: python
  
              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]
docstring_summary: :api_attr: Static Graph
docstring_tokens: : api_attr : Static Graph
function: def group_norm(input,
                 groups,
                 epsilon=1e-05,
                 param_attr=None,
                 bias_attr=None,
                 act=None,
                 data_layout='NCHW',
                 name=None):
      """
      :api_attr: Static Graph
  
      **Group Normalization Layer**
  
      Refer to `Group Normalization <https://arxiv.org/abs/1803.08494>`_ .
  
      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 :ref:`api_guide_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 :ref:`api_guide_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 :ref:`api_guide_Name` .
  
      Returns:
          Tensor: A Tensor has same data type and data format with `input`.
  
      Examples:
         .. code-block:: python
  
              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]
      """
      helper = LayerHelper('group_norm', **locals())
      dtype = helper.input_dtype()
      check_variable_and_dtype(input, 'input', ['float32', 'float64'],
                               'group_norm')
      # create intput and parameters
      inputs = {'X': input}
      input_shape = input.shape
      if len(input_shape) < 2:
          raise ValueError(
              f"The dimensions of Op(fluid.layers.group_norm)'s input should be more than 1. But received {len(input_shape)}"
          )
      if data_layout != 'NCHW' and data_layout != 'NHWC':
          raise ValueError(
              "Param(data_layout) of Op(fluid.layers.group_norm) got wrong value: received "
              + data_layout + " but only NCHW or NHWC supported.")
      channel_num = input_shape[1] if data_layout == 'NCHW' else input_shape[-1]
      param_shape = [channel_num]
      if param_attr:
          scale = helper.create_parameter(
              attr=helper.param_attr,
              shape=param_shape,
              dtype=dtype,
              default_initializer=Constant(1.0))
          inputs['Scale'] = scale
      if bias_attr:
          bias = helper.create_parameter(
              attr=helper.bias_attr, shape=param_shape, dtype=dtype, is_bias=True)
          inputs['Bias'] = bias
  
      # create output
      mean_out = helper.create_variable(dtype=dtype, stop_gradient=True)
      variance_out = helper.create_variable(dtype=dtype, stop_gradient=True)
      group_norm_out = helper.create_variable(dtype=dtype)
  
      helper.append_op(
          type="group_norm",
          inputs=inputs,
          outputs={
              "Y": group_norm_out,
              "Mean": mean_out,
              "Variance": variance_out,
          },
          attrs={
              "epsilon": epsilon,
              "groups": groups,
              "data_layout": data_layout
          })
  
      return helper.append_activation(group_norm_out)
function_tokens: def group_norm ( input , groups , epsilon = 1e-05 , param_attr = None , bias_attr = None , act = None , data_layout = 'NCHW' , name = None ) : helper = LayerHelper ( 'group_norm' , * * locals ( ) ) dtype = helper . input_dtype ( ) check_variable_and_dtype ( input , 'input' , [ 'float32' , 'float64' ] , 'group_norm' ) # create intput and parameters inputs = { 'X' : input } input_shape = input . shape if len ( input_shape ) < 2 : raise ValueError ( f"The dimensions of Op(fluid.layers.group_norm)'s input should be more than 1. But received {len(input_shape)}" ) if data_layout != 'NCHW' and data_layout != 'NHWC' : raise ValueError ( "Param(data_layout) of Op(fluid.layers.group_norm) got wrong value: received " + data_layout + " but only NCHW or NHWC supported." ) channel_num = input_shape [ 1 ] if data_layout == 'NCHW' else input_shape [ - 1 ] param_shape = [ channel_num ] if param_attr : scale = helper . create_parameter ( attr = helper . param_attr , shape = param_shape , dtype = dtype , default_initializer = Constant ( 1.0 ) ) inputs [ 'Scale' ] = scale if bias_attr : bias = helper . create_parameter ( attr = helper . bias_attr , shape = param_shape , dtype = dtype , is_bias = True ) inputs [ 'Bias' ] = bias # create output mean_out = helper . create_variable ( dtype = dtype , stop_gradient = True ) variance_out = helper . create_variable ( dtype = dtype , stop_gradient = True ) group_norm_out = helper . create_variable ( dtype = dtype ) helper . append_op ( type = "group_norm" , inputs = inputs , outputs = { "Y" : group_norm_out , "Mean" : mean_out , "Variance" : variance_out , } , attrs = { "epsilon" : epsilon , "groups" : groups , "data_layout" : data_layout } ) return helper . append_activation ( group_norm_out )