(inputs, is_training, center=True, scale=True, name="batch_norm")
Performs the vanilla batch normalization with trainable scaling and offset.

  Args:
    inputs: A tensor with 2 or 4 dimensions, where the first dimension is
      `batch_size`. The normalization is over all but the last dimension if
      `data_format` is `NHWC`, and the second dimension if `data_format` is
      `NCHW`.
    is_training: Whether or not the layer is in training mode.
    center: If True, add offset of beta to normalized tensor.
    scale: If True, multiply by gamma. When the next layer is linear  this can
      be disabled since the scaling will be done by the next layer.
    name: Name of the variable scope.

  Returns:
    The normalized tensor with the same type and shape as `inputs`.
Performs the vanilla batch normalization with trainable scaling and offset.
Performs the vanilla batch normalization with trainable scaling and offset .
def batch_norm(inputs, is_training, center=True, scale=True, name="batch_norm"):
  """Performs the vanilla batch normalization with trainable scaling and offset.

  Args:
    inputs: A tensor with 2 or 4 dimensions, where the first dimension is
      `batch_size`. The normalization is over all but the last dimension if
      `data_format` is `NHWC`, and the second dimension if `data_format` is
      `NCHW`.
    is_training: Whether or not the layer is in training mode.
    center: If True, add offset of beta to normalized tensor.
    scale: If True, multiply by gamma. When the next layer is linear  this can
      be disabled since the scaling will be done by the next layer.
    name: Name of the variable scope.

  Returns:
    The normalized tensor with the same type and shape as `inputs`.
  """
  with tf.variable_scope(name, values=[inputs]):
    outputs = standardize_batch(inputs, is_training=is_training)
    num_channels = inputs.shape[-1].value

    # Allocate parameters for the trainable variables.
    collections = [tf.GraphKeys.MODEL_VARIABLES,
                   tf.GraphKeys.GLOBAL_VARIABLES]
    if scale:
      gamma = tf.get_variable(
          "gamma",
          [num_channels],
          collections=collections,
          initializer=tf.ones_initializer())
      outputs *= gamma
    if center:
      beta = tf.get_variable(
          "beta",
          [num_channels],
          collections=collections,
          initializer=tf.zeros_initializer())
      outputs += beta
    return outputs
def batch_norm ( inputs , is_training , center = True , scale = True , name = "batch_norm" ) : with tf . variable_scope ( name , values = [ inputs ] ) : outputs = standardize_batch ( inputs , is_training = is_training ) num_channels = inputs . shape [ - 1 ] . value # Allocate parameters for the trainable variables. collections = [ tf . GraphKeys . MODEL_VARIABLES , tf . GraphKeys . GLOBAL_VARIABLES ] if scale : gamma = tf . get_variable ( "gamma" , [ num_channels ] , collections = collections , initializer = tf . ones_initializer ( ) ) outputs *= gamma if center : beta = tf . get_variable ( "beta" , [ num_channels ] , collections = collections , initializer = tf . zeros_initializer ( ) ) outputs += beta return outputs