diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index 433d93c0c179cc6a2147c42e564c0af9834fd375..56bb4201994d9643b06a27d9c42d353b657d1774 100755 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -188,7 +188,7 @@ paddle.fluid.layers.beam_search (ArgSpec(args=['pre_ids', 'pre_scores', 'ids', ' paddle.fluid.layers.row_conv (ArgSpec(args=['input', 'future_context_size', 'param_attr', 'act'], varargs=None, keywords=None, defaults=(None, None)), ('document', '1d8a1c8b686b55631ba1b77805e4eacf')) paddle.fluid.layers.multiplex (ArgSpec(args=['inputs', 'index'], varargs=None, keywords=None, defaults=None), ('document', '2c4d1ae83da6ed35e3b36ba1b3b51d23')) paddle.fluid.layers.layer_norm (ArgSpec(args=['input', 'scale', 'shift', 'begin_norm_axis', 'epsilon', 'param_attr', 'bias_attr', 'act', 'name'], varargs=None, keywords=None, defaults=(True, True, 1, 1e-05, None, None, None, None)), ('document', '79797f827d89ae72c77960e9696883a9')) -paddle.fluid.layers.group_norm (ArgSpec(args=['input', 'groups', 'epsilon', 'param_attr', 'bias_attr', 'act', 'data_layout', 'name'], varargs=None, keywords=None, defaults=(1e-05, None, None, None, 'NCHW', None)), ('document', '65231cc8281815124934b1439fbb750c')) +paddle.fluid.layers.group_norm (ArgSpec(args=['input', 'groups', 'epsilon', 'param_attr', 'bias_attr', 'act', 'data_layout', 'name'], varargs=None, keywords=None, defaults=(1e-05, None, None, None, 'NCHW', None)), ('document', '87dd4b818f102bc1a780e1804c28bd38')) paddle.fluid.layers.spectral_norm (ArgSpec(args=['weight', 'dim', 'power_iters', 'eps', 'name'], varargs=None, keywords=None, defaults=(0, 1, 1e-12, None)), ('document', '9461e67095a6fc5d568fb2ce8fef66ff')) paddle.fluid.layers.softmax_with_cross_entropy (ArgSpec(args=['logits', 'label', 'soft_label', 'ignore_index', 'numeric_stable_mode', 'return_softmax', 'axis'], varargs=None, keywords=None, defaults=(False, -100, True, False, -1)), ('document', '54e1675aa0364f4a78fa72804ec0f413')) paddle.fluid.layers.smooth_l1 (ArgSpec(args=['x', 'y', 'inside_weight', 'outside_weight', 'sigma'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', 'cbe8940643ac80ef75e1abdfbdb09e88')) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index ae463ce449807bf78e926d197e7bda09e5f7b263..43406a551d9f1b00340719d5da664beff007ba5b 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -4306,30 +4306,39 @@ def group_norm(input, Refer to `Group Normalization `_ . - Args: - input(Variable): The input tensor variable. - groups(int): The number of groups that divided from channels. - epsilon(float): The small value added to the variance to prevent - division by zero. - param_attr(ParamAttr|None): The parameter attribute for the learnable - scale :math:`g`. If it is set to False, no scale will be added to the output units. - If it is set to None, the bias is initialized one. Default: None. - bias_attr(ParamAttr|None): The parameter attribute for the learnable - bias :math:`b`. If it is set to False, no bias will be added to the output units. - If it is set to None, the bias is initialized zero. Default: None. - act(str): Activation to be applied to the output of group normalizaiton. - data_layout(string, default NCHW): NCHW(num_batch, channels, h, w) or NHWC(num_batch, h, w, channels). - name (str): The name of this layer. It is optional. + 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 :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 normalizaiton. + data_layout(str, optional): The data format of the input and output data. An optional string + from: `"NCHW"`, `"NHWC"`. When it is `"NCHW"`, the data is stored in the order of: + `[batch_size, channels, height, width]`. Default: "NCHW". + 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: - Variable: A tensor variable which is the result after applying group normalization on the input. + Variable: A 4-D Tensor has same data type and data format with `input`. + + Raises: + ValueError: If `data_layout` is neither 'NCHW' nor 'NHWC'. Examples: + .. code-block:: python - >>> import paddle.fluid as fluid - >>> data = fluid.layers.data(name='data', shape=[8, 32, 32], - >>> dtype='float32') - >>> x = fluid.layers.group_norm(input=data, groups=4) + 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) """ helper = LayerHelper('group_norm', **locals()) dtype = helper.input_dtype()