parameters: (input,
                  act=None,
                  is_test=False,
                  momentum=0.9,
                  epsilon=1e-05,
                  param_attr=None,
                  bias_attr=None,
                  data_layout='NCHW',
                  name=None,
                  moving_mean_name=None,
                  moving_variance_name=None,
                  do_model_average_for_mean_and_var=True,
                  use_global_stats=False,
                  act_alpha=1.0)
return_statement: return batch_norm_out
docstring: r"""
      **In-place Activation Batch Normalization Layer**
  
      This layer calculates batch normalization and activation with in-place memory.
      For batch normalization calculations, see `fluid.layers.batch_norm`.
      For in-place activation batch normalization, see `In-Place Activated BatchNorm for
      Memory-Optimized Training of DNNs <https://arxiv.org/abs/1712.02616>`_
  
      `inplace_abn` only support activation type as `None`, `identity`, `leaky_relu`,
      `elu` currently.
      `inplace_abn` only support data type as `float32`, `float64` currently.
  
      Note:
          if build_strategy.sync_batch_norm=True, the batch_norm in network will use
          sync_batch_norm automatically.
          `is_test = True` can only be used in test program and inference program, `is_test` CANNOT be set to True in train program, if you want to use global status from pre_train model in train program, please set `use_global_stats = True`.
  
      Args:
          input(Variable): The rank of input variable can be 2, 3, 4, 5. The data type
              is float16 or float32 or float64.
          act(string, Default None): Activation type, linear|relu|prelu|...
          is_test (bool, Default False): A flag indicating whether it is in
              test phrase or not.
          momentum(float|Variable, Default 0.9): The value used for the moving_mean and
              moving_var computation. This should be a float number or a Variable with
              shape [1] and data type as float32. The updated formula is:
              :math:`moving\_mean = moving\_mean * momentum + new\_mean * (1. - momentum)`
              :math:`moving\_var = moving\_var * momentum + new\_var * (1. - momentum)`
              Default is 0.9.
          epsilon(float, Default 1e-05): A value added to the denominator for
              numerical stability. Default is 1e-5.
          param_attr(ParamAttr|None): The parameter attribute for Parameter `scale`
               of inplace_abn. If it is set to None or one attribute of ParamAttr, inplace_abn
  	     will create ParamAttr as param_attr, the name of scale can be set in ParamAttr.
  	     If the Initializer of the param_attr is not set, the parameter is initialized
  	     with Xavier. Default: None.
          bias_attr(ParamAttr|None): The parameter attribute for the bias of inplace_abn.
               If it is set to None or one attribute of ParamAttr, inplace_abn
  	     will create ParamAttr as bias_attr, the name of bias can be set in ParamAttr.
  	     If the Initializer of the bias_attr is not set, the bias is initialized zero.
  	     Default: None.
          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|None): For detailed information, please refer to :ref:`api_guide_Name`.
              Usually name is no need to set and None by default.
          moving_mean_name(str, Default None): The name of moving_mean which store the global Mean. If it
              is set to None, inplace_abn will save global mean with a random name, otherwise, inplace_abn
              will save global mean with the string.
          moving_variance_name(str, Default None): The name of the moving_variance which store the global Variance.
              If it is set to None, inplace_abn, will save global variance with a random name, otherwise, inplace_abn
              will save global variance with the string.
          do_model_average_for_mean_and_var(bool, Default True): Whether parameter mean and variance should do model
              average when model average is enabled.
          use_global_stats(bool, Default False): Whether to use global mean and
              variance. In inference or test mode, set use_global_stats to true
              or is_test to true, and the behavior is equivalent.
              In train mode, when setting use_global_stats True, the global mean
              and variance are also used during train period.
          act_alpha(float, Default 1.0): when activation is in ['elu', 'identity', 'leaky_relu'],
              inplace activative batch normalization will be used, and alpha parameter for activation
              can be given by this parameter.
      Returns:
          A Variable holding Tensor which is the result after applying batch normalization and activation on the input,
          has same shape and data type with input.
  
      Examples:
  
          .. code-block:: python
  
              import paddle.fluid as fluid
              x = fluid.data(name='x', shape=[3, 7, 3, 7], dtype='float32')
              hidden1 = fluid.layers.fc(input=x, size=200, param_attr='fc1.w')
              hidden2 = fluid.layers.inplace_abn(input=hidden1)
              hidden3 = fluid.layers.inplace_abn(input=hidden2, act='leaky_relu', act_alpha=0.2)
docstring_summary: r"""
      **In-place Activation Batch Normalization Layer**
docstring_tokens: r ** In - place Activation Batch Normalization Layer **
function: def inplace_abn(input,
                  act=None,
                  is_test=False,
                  momentum=0.9,
                  epsilon=1e-05,
                  param_attr=None,
                  bias_attr=None,
                  data_layout='NCHW',
                  name=None,
                  moving_mean_name=None,
                  moving_variance_name=None,
                  do_model_average_for_mean_and_var=True,
                  use_global_stats=False,
                  act_alpha=1.0):
      r"""
      **In-place Activation Batch Normalization Layer**
  
      This layer calculates batch normalization and activation with in-place memory.
      For batch normalization calculations, see `fluid.layers.batch_norm`.
      For in-place activation batch normalization, see `In-Place Activated BatchNorm for
      Memory-Optimized Training of DNNs <https://arxiv.org/abs/1712.02616>`_
  
      `inplace_abn` only support activation type as `None`, `identity`, `leaky_relu`,
      `elu` currently.
      `inplace_abn` only support data type as `float32`, `float64` currently.
  
      Note:
          if build_strategy.sync_batch_norm=True, the batch_norm in network will use
          sync_batch_norm automatically.
          `is_test = True` can only be used in test program and inference program, `is_test` CANNOT be set to True in train program, if you want to use global status from pre_train model in train program, please set `use_global_stats = True`.
  
      Args:
          input(Variable): The rank of input variable can be 2, 3, 4, 5. The data type
              is float16 or float32 or float64.
          act(string, Default None): Activation type, linear|relu|prelu|...
          is_test (bool, Default False): A flag indicating whether it is in
              test phrase or not.
          momentum(float|Variable, Default 0.9): The value used for the moving_mean and
              moving_var computation. This should be a float number or a Variable with
              shape [1] and data type as float32. The updated formula is:
              :math:`moving\_mean = moving\_mean * momentum + new\_mean * (1. - momentum)`
              :math:`moving\_var = moving\_var * momentum + new\_var * (1. - momentum)`
              Default is 0.9.
          epsilon(float, Default 1e-05): A value added to the denominator for
              numerical stability. Default is 1e-5.
          param_attr(ParamAttr|None): The parameter attribute for Parameter `scale`
               of inplace_abn. If it is set to None or one attribute of ParamAttr, inplace_abn
  	     will create ParamAttr as param_attr, the name of scale can be set in ParamAttr.
  	     If the Initializer of the param_attr is not set, the parameter is initialized
  	     with Xavier. Default: None.
          bias_attr(ParamAttr|None): The parameter attribute for the bias of inplace_abn.
               If it is set to None or one attribute of ParamAttr, inplace_abn
  	     will create ParamAttr as bias_attr, the name of bias can be set in ParamAttr.
  	     If the Initializer of the bias_attr is not set, the bias is initialized zero.
  	     Default: None.
          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|None): For detailed information, please refer to :ref:`api_guide_Name`.
              Usually name is no need to set and None by default.
          moving_mean_name(str, Default None): The name of moving_mean which store the global Mean. If it
              is set to None, inplace_abn will save global mean with a random name, otherwise, inplace_abn
              will save global mean with the string.
          moving_variance_name(str, Default None): The name of the moving_variance which store the global Variance.
              If it is set to None, inplace_abn, will save global variance with a random name, otherwise, inplace_abn
              will save global variance with the string.
          do_model_average_for_mean_and_var(bool, Default True): Whether parameter mean and variance should do model
              average when model average is enabled.
          use_global_stats(bool, Default False): Whether to use global mean and
              variance. In inference or test mode, set use_global_stats to true
              or is_test to true, and the behavior is equivalent.
              In train mode, when setting use_global_stats True, the global mean
              and variance are also used during train period.
          act_alpha(float, Default 1.0): when activation is in ['elu', 'identity', 'leaky_relu'],
              inplace activative batch normalization will be used, and alpha parameter for activation
              can be given by this parameter.
      Returns:
          A Variable holding Tensor which is the result after applying batch normalization and activation on the input,
          has same shape and data type with input.
  
      Examples:
  
          .. code-block:: python
  
              import paddle.fluid as fluid
              x = fluid.data(name='x', shape=[3, 7, 3, 7], dtype='float32')
              hidden1 = fluid.layers.fc(input=x, size=200, param_attr='fc1.w')
              hidden2 = fluid.layers.inplace_abn(input=hidden1)
              hidden3 = fluid.layers.inplace_abn(input=hidden2, act='leaky_relu', act_alpha=0.2)
  
      """
      assert act in [None, 'identity', 'leaky_relu', 'elu'], \
          "inplace_abn only support act as None, 'identity', " \
          "'leaky_relu', 'elu' currently"
      assert bias_attr is not False, "bias_attr should not be False in inplace_abn."
      helper = LayerHelper('inplace_abn', **locals())
  
      check_variable_and_dtype(input, 'input', ['float32', 'float64'],
                               'inplace_abn')
      dtype = helper.input_dtype()
  
      input_shape = input.shape
      if data_layout == 'NCHW':
          channel_num = input_shape[1]
      else:
          if data_layout == 'NHWC':
              channel_num = input_shape[-1]
          else:
              raise ValueError("unsupported data layout:" + data_layout)
  
      param_shape = [channel_num]
  
      # create parameter
      scale = helper.create_parameter(
          attr=helper.param_attr,
          shape=param_shape,
          dtype=dtype,
          default_initializer=Constant(1.0))
      bias = helper.create_parameter(
          attr=helper.bias_attr, shape=param_shape, dtype=dtype, is_bias=True)
  
      mean = helper.create_parameter(
          attr=ParamAttr(
              name=moving_mean_name,
              initializer=Constant(0.0),
              trainable=False,
              do_model_average=do_model_average_for_mean_and_var),
          shape=param_shape,
          dtype=dtype)
      mean.stop_gradient = True
  
      variance = helper.create_parameter(
          attr=ParamAttr(
              name=moving_variance_name,
              initializer=Constant(1.0),
              trainable=False,
              do_model_average=do_model_average_for_mean_and_var),
          shape=param_shape,
          dtype=dtype)
      variance.stop_gradient = True
  
      # create output
      # mean and mean_out share the same memory
      mean_out = mean
      # variance and variance out share the same memory
      variance_out = variance
      saved_mean = helper.create_variable_for_type_inference(
          dtype=dtype, stop_gradient=True)
      saved_variance = helper.create_variable_for_type_inference(
          dtype=dtype, stop_gradient=True)
      reserve_space = helper.create_variable_for_type_inference(
          dtype=dtype, stop_gradient=True)
      batch_norm_out = input
  
      inputs = {
          "X": input,
          "Scale": scale,
          "Bias": bias,
          "Mean": mean,
          "Variance": variance
      }
      attrs = {
          "epsilon": epsilon,
          "is_test": is_test,
          "data_layout": data_layout,
          "use_mkldnn": False,
          "fuse_with_relu": False,
          "use_global_stats": use_global_stats,
          "activation": act,
          "alpha": act_alpha,
      }
      if isinstance(momentum, Variable):
          inputs['MomemtumTensor'] = momentum
      else:
          attrs['momentum'] = momentum
      outputs = {
          "Y": batch_norm_out,
          "MeanOut": mean_out,
          "VarianceOut": variance_out,
          "SavedMean": saved_mean,
          "SavedVariance": saved_variance
      }
      if reserve_space is not None:
          outputs["ReserveSpace"] = reserve_space
  
      helper.append_op(
          type="inplace_abn", inputs=inputs, outputs=outputs, attrs=attrs)
  
      return batch_norm_out
function_tokens: def inplace_abn ( input , act = None , is_test = False , momentum = 0.9 , epsilon = 1e-05 , param_attr = None , bias_attr = None , data_layout = 'NCHW' , name = None , moving_mean_name = None , moving_variance_name = None , do_model_average_for_mean_and_var = True , use_global_stats = False , act_alpha = 1.0 ) : assert act in [ None , 'identity' , 'leaky_relu' , 'elu' ] , "inplace_abn only support act as None, 'identity', " "'leaky_relu', 'elu' currently" assert bias_attr is not False , "bias_attr should not be False in inplace_abn." helper = LayerHelper ( 'inplace_abn' , * * locals ( ) ) check_variable_and_dtype ( input , 'input' , [ 'float32' , 'float64' ] , 'inplace_abn' ) dtype = helper . input_dtype ( ) input_shape = input . shape if data_layout == 'NCHW' : channel_num = input_shape [ 1 ] else : if data_layout == 'NHWC' : channel_num = input_shape [ - 1 ] else : raise ValueError ( "unsupported data layout:" + data_layout ) param_shape = [ channel_num ] # create parameter scale = helper . create_parameter ( attr = helper . param_attr , shape = param_shape , dtype = dtype , default_initializer = Constant ( 1.0 ) ) bias = helper . create_parameter ( attr = helper . bias_attr , shape = param_shape , dtype = dtype , is_bias = True ) mean = helper . create_parameter ( attr = ParamAttr ( name = moving_mean_name , initializer = Constant ( 0.0 ) , trainable = False , do_model_average = do_model_average_for_mean_and_var ) , shape = param_shape , dtype = dtype ) mean . stop_gradient = True variance = helper . create_parameter ( attr = ParamAttr ( name = moving_variance_name , initializer = Constant ( 1.0 ) , trainable = False , do_model_average = do_model_average_for_mean_and_var ) , shape = param_shape , dtype = dtype ) variance . stop_gradient = True # create output # mean and mean_out share the same memory mean_out = mean # variance and variance out share the same memory variance_out = variance saved_mean = helper . create_variable_for_type_inference ( dtype = dtype , stop_gradient = True ) saved_variance = helper . create_variable_for_type_inference ( dtype = dtype , stop_gradient = True ) reserve_space = helper . create_variable_for_type_inference ( dtype = dtype , stop_gradient = True ) batch_norm_out = input inputs = { "X" : input , "Scale" : scale , "Bias" : bias , "Mean" : mean , "Variance" : variance } attrs = { "epsilon" : epsilon , "is_test" : is_test , "data_layout" : data_layout , "use_mkldnn" : False , "fuse_with_relu" : False , "use_global_stats" : use_global_stats , "activation" : act , "alpha" : act_alpha , } if isinstance ( momentum , Variable ) : inputs [ 'MomemtumTensor' ] = momentum else : attrs [ 'momentum' ] = momentum outputs = { "Y" : batch_norm_out , "MeanOut" : mean_out , "VarianceOut" : variance_out , "SavedMean" : saved_mean , "SavedVariance" : saved_variance } if reserve_space is not None : outputs [ "ReserveSpace" ] = reserve_space helper . append_op ( type = "inplace_abn" , inputs = inputs , outputs = outputs , attrs = attrs ) return batch_norm_out