(mean, variance, is_training, decay)
return moving_mean, moving_variance
Use moving averages of moments during inference.

  Args:
    mean: Tensor of shape [num_channels] with the mean of the current batch.
    variance: Tensor of shape [num_channels] with the variance of the current
      batch.
    is_training: Boolean, wheather to construct ops for training or inference
      graph.
    decay: Decay rate to use for moving averages.

  Returns:
    Tuple of (mean, variance) to use. This can the same as the inputs.
Use moving averages of moments during inference.
Use moving averages of moments during inference .
def _moving_moments_for_inference(mean, variance, is_training, decay):
  """Use moving averages of moments during inference.

  Args:
    mean: Tensor of shape [num_channels] with the mean of the current batch.
    variance: Tensor of shape [num_channels] with the variance of the current
      batch.
    is_training: Boolean, wheather to construct ops for training or inference
      graph.
    decay: Decay rate to use for moving averages.

  Returns:
    Tuple of (mean, variance) to use. This can the same as the inputs.
  """
  # Create the moving average variables and add them to the appropriate
  # collections.
  variable_collections = [
      tf.GraphKeys.MOVING_AVERAGE_VARIABLES,
      tf.GraphKeys.MODEL_VARIABLES, tf.GraphKeys.GLOBAL_VARIABLES,
  ]
  # Disable partition setting for moving_mean and moving_variance
  # as assign_moving_average op below doesn"t support partitioned variable.
  moving_mean = tf.get_variable(
      "moving_mean",
      shape=mean.shape,
      initializer=tf.zeros_initializer(),
      trainable=False,
      partitioner=None,
      collections=variable_collections)
  moving_variance = tf.get_variable(
      "moving_variance",
      shape=variance.shape,
      initializer=tf.ones_initializer(),
      trainable=False,
      partitioner=None,
      collections=variable_collections)
  if is_training:
    logging.debug("Adding update ops for moving averages of mean and variance.")
    # Update variables for mean and variance during training.
    update_moving_mean = moving_averages.assign_moving_average(
        moving_mean,
        tf.cast(mean, moving_mean.dtype),
        decay,
        zero_debias=False)
    update_moving_variance = moving_averages.assign_moving_average(
        moving_variance,
        tf.cast(variance, moving_variance.dtype),
        decay,
        zero_debias=False)
    tf.add_to_collection(tf.GraphKeys.UPDATE_OPS, update_moving_mean)
    tf.add_to_collection(tf.GraphKeys.UPDATE_OPS, update_moving_variance)
    return mean, variance
  logging.debug("Using moving mean and variance.")
  return moving_mean, moving_variance
def _moving_moments_for_inference ( mean , variance , is_training , decay ) : # Create the moving average variables and add them to the appropriate # collections. variable_collections = [ tf . GraphKeys . MOVING_AVERAGE_VARIABLES , tf . GraphKeys . MODEL_VARIABLES , tf . GraphKeys . GLOBAL_VARIABLES , ] # Disable partition setting for moving_mean and moving_variance # as assign_moving_average op below doesn"t support partitioned variable. moving_mean = tf . get_variable ( "moving_mean" , shape = mean . shape , initializer = tf . zeros_initializer ( ) , trainable = False , partitioner = None , collections = variable_collections ) moving_variance = tf . get_variable ( "moving_variance" , shape = variance . shape , initializer = tf . ones_initializer ( ) , trainable = False , partitioner = None , collections = variable_collections ) if is_training : logging . debug ( "Adding update ops for moving averages of mean and variance." ) # Update variables for mean and variance during training. update_moving_mean = moving_averages . assign_moving_average ( moving_mean , tf . cast ( mean , moving_mean . dtype ) , decay , zero_debias = False ) update_moving_variance = moving_averages . assign_moving_average ( moving_variance , tf . cast ( variance , moving_variance . dtype ) , decay , zero_debias = False ) tf . add_to_collection ( tf . GraphKeys . UPDATE_OPS , update_moving_mean ) tf . add_to_collection ( tf . GraphKeys . UPDATE_OPS , update_moving_variance ) return mean , variance logging . debug ( "Using moving mean and variance." ) return moving_mean , moving_variance