(x,
                            bn_weight_decay,
                            scope_name='batch_norm_for_set_encoder')
Batch normalization for use in the DeepSet encoder.

  Args:
    x: inputs.
    bn_weight_decay: Weight decay for scale and offset parameters.
    scope_name: A string. The scope name.

  Returns:
    output: The result of applying batch normalization to the input.
Batch normalization for use in the DeepSet encoder.
Batch normalization for use in the DeepSet encoder .
def bn_for_deep_set_encoder(x,
                            bn_weight_decay,
                            scope_name='batch_norm_for_set_encoder'):
  """Batch normalization for use in the DeepSet encoder.

  Args:
    x: inputs.
    bn_weight_decay: Weight decay for scale and offset parameters.
    scope_name: A string. The scope name.

  Returns:
    output: The result of applying batch normalization to the input.
  """
  with tf.variable_scope(scope_name):
    # Compute the mean and var of the current batch. [1, 1, 1, num channels].
    mean, var = tf.nn.moments(
        x, axes=list(range(len(x.shape) - 1)), keep_dims=True)
    num_channels = mean.shape[-1]

    # [num channels].
    offset = tf.get_variable(
        'offset',
        shape=[num_channels],
        initializer=tf.initializers.zeros(),
        regularizer=tf.keras.regularizers.L2(bn_weight_decay))
    # We init the scale to zeros and then add 1 (instead of init at 1) so that
    # the weight decay regularizes the scale parameters towards unity.
    scale = tf.get_variable(
        'scale',
        shape=[num_channels],
        initializer=tf.initializers.zeros(),
        regularizer=tf.keras.regularizers.L2(bn_weight_decay))
    scale = scale + 1

    output = tf.nn.batch_normalization(x, mean, var, offset, scale, 0.00001)
    return output
def bn_for_deep_set_encoder ( x , bn_weight_decay , scope_name = 'batch_norm_for_set_encoder' ) : with tf . variable_scope ( scope_name ) : # Compute the mean and var of the current batch. [1, 1, 1, num channels]. mean , var = tf . nn . moments ( x , axes = list ( range ( len ( x . shape ) - 1 ) ) , keep_dims = True ) num_channels = mean . shape [ - 1 ] # [num channels]. offset = tf . get_variable ( 'offset' , shape = [ num_channels ] , initializer = tf . initializers . zeros ( ) , regularizer = tf . keras . regularizers . L2 ( bn_weight_decay ) ) # We init the scale to zeros and then add 1 (instead of init at 1) so that # the weight decay regularizes the scale parameters towards unity. scale = tf . get_variable ( 'scale' , shape = [ num_channels ] , initializer = tf . initializers . zeros ( ) , regularizer = tf . keras . regularizers . L2 ( bn_weight_decay ) ) scale = scale + 1 output = tf . nn . batch_normalization ( x , mean , var , offset , scale , 0.00001 ) return output