(clone, num_clones, regularization_losses)
return sum_loss
Gather the loss for a single clone.

  Args:
    clone: A Clone namedtuple.
    num_clones: The number of clones being deployed.
    regularization_losses: Possibly empty list of regularization_losses
      to add to the clone losses.

  Returns:
    A tensor for the total loss for the clone.  Can be None.
Gather the loss for a single clone.
Gather the loss for a single clone .
def _gather_clone_loss(clone, num_clones, regularization_losses):
  """Gather the loss for a single clone.

  Args:
    clone: A Clone namedtuple.
    num_clones: The number of clones being deployed.
    regularization_losses: Possibly empty list of regularization_losses
      to add to the clone losses.

  Returns:
    A tensor for the total loss for the clone.  Can be None.
  """
  # The return value.
  sum_loss = None
  # Individual components of the loss that will need summaries.
  clone_loss = None
  regularization_loss = None
  # Compute and aggregate losses on the clone device.
  with tf.device(clone.device):
    all_losses = []
    clone_losses = tf.get_collection(tf.GraphKeys.LOSSES, clone.scope)
    if clone_losses:
      clone_loss = tf.add_n(clone_losses, name='clone_loss')
      if num_clones > 1:
        clone_loss = tf.div(clone_loss, 1.0 * num_clones,
                            name='scaled_clone_loss')
      all_losses.append(clone_loss)
    if regularization_losses:
      regularization_loss = tf.add_n(regularization_losses,
                                     name='regularization_loss')
      all_losses.append(regularization_loss)
    if all_losses:
      sum_loss = tf.add_n(all_losses)
  # Add the summaries out of the clone device block.
  if clone_loss is not None:
    tf.summary.scalar(clone.scope + '/clone_loss', clone_loss)
  if regularization_loss is not None:
    tf.summary.scalar('regularization_loss', regularization_loss)
  return sum_loss
def _gather_clone_loss ( clone , num_clones , regularization_losses ) : # The return value. sum_loss = None # Individual components of the loss that will need summaries. clone_loss = None regularization_loss = None # Compute and aggregate losses on the clone device. with tf . device ( clone . device ) : all_losses = [ ] clone_losses = tf . get_collection ( tf . GraphKeys . LOSSES , clone . scope ) if clone_losses : clone_loss = tf . add_n ( clone_losses , name = 'clone_loss' ) if num_clones > 1 : clone_loss = tf . div ( clone_loss , 1.0 * num_clones , name = 'scaled_clone_loss' ) all_losses . append ( clone_loss ) if regularization_losses : regularization_loss = tf . add_n ( regularization_losses , name = 'regularization_loss' ) all_losses . append ( regularization_loss ) if all_losses : sum_loss = tf . add_n ( all_losses ) # Add the summaries out of the clone device block. if clone_loss is not None : tf . summary . scalar ( clone . scope + '/clone_loss' , clone_loss ) if regularization_loss is not None : tf . summary . scalar ( 'regularization_loss' , regularization_loss ) return sum_loss