parameters: (predictions, targets, weight=1.0, scope=None)
docstring: Adds a pairwise-errors-squared loss to the training procedure.
  
    Unlike the sum_of_squares loss, which is a measure of the differences between
    corresponding elements of `predictions` and `targets`, sum_of_pairwise_squares
    is a measure of the differences between pairs of corresponding elements of
    `predictions` and `targets`.
  
    For example, if `targets`=[a, b, c] and `predictions`=[x, y, z], there are
    three pairs of differences are summed to compute the loss:
      loss = [ ((a-b) - (x-y)).^2 + ((a-c) - (x-z)).^2 + ((b-c) - (y-z)).^2 ] / 3
  
    Note that since the inputs are of size [batch_size, d0, ... dN], the
    corresponding pairs are computed within each batch sample but not across
    samples within a batch. For example, if `predictions` represents a batch of
    16 grayscale images of dimenion [batch_size, 100, 200], then the set of pairs
    is drawn from each image, but not across images.
  
    `weight` acts as a coefficient for the loss. If a scalar is provided, then the
    loss is simply scaled by the given value. If `weight` is a tensor of size
    [batch_size], then the total loss for each sample of the batch is rescaled
    by the corresponding element in the `weight` vector.
  
    Args:
      predictions: The predicted outputs, a tensor of size [batch_size, d0, .. dN]
        where N+1 is the total number of dimensions in `predictions`.
      targets: The ground truth output tensor, whose shape must match the shape of
        the `predictions` tensor.
      weight: Coefficients for the loss a scalar, a tensor of shape [batch_size]
        or a tensor whose shape matches `predictions`.
      scope: The scope for the operations performed in computing the loss.
  
    Returns:
      A scalar `Tensor` representing the loss value.
  
    Raises:
      ValueError: If the shape of `predictions` doesn't match that of `targets` or
        if the shape of `weight` is invalid.
docstring_summary: Adds a pairwise-errors-squared loss to the training procedure.
docstring_tokens: Adds a pairwise - errors - squared loss to the training procedure .
function: def sum_of_pairwise_squares(predictions, targets, weight=1.0, scope=None):
    """Adds a pairwise-errors-squared loss to the training procedure.
  
    Unlike the sum_of_squares loss, which is a measure of the differences between
    corresponding elements of `predictions` and `targets`, sum_of_pairwise_squares
    is a measure of the differences between pairs of corresponding elements of
    `predictions` and `targets`.
  
    For example, if `targets`=[a, b, c] and `predictions`=[x, y, z], there are
    three pairs of differences are summed to compute the loss:
      loss = [ ((a-b) - (x-y)).^2 + ((a-c) - (x-z)).^2 + ((b-c) - (y-z)).^2 ] / 3
  
    Note that since the inputs are of size [batch_size, d0, ... dN], the
    corresponding pairs are computed within each batch sample but not across
    samples within a batch. For example, if `predictions` represents a batch of
    16 grayscale images of dimenion [batch_size, 100, 200], then the set of pairs
    is drawn from each image, but not across images.
  
    `weight` acts as a coefficient for the loss. If a scalar is provided, then the
    loss is simply scaled by the given value. If `weight` is a tensor of size
    [batch_size], then the total loss for each sample of the batch is rescaled
    by the corresponding element in the `weight` vector.
  
    Args:
      predictions: The predicted outputs, a tensor of size [batch_size, d0, .. dN]
        where N+1 is the total number of dimensions in `predictions`.
      targets: The ground truth output tensor, whose shape must match the shape of
        the `predictions` tensor.
      weight: Coefficients for the loss a scalar, a tensor of shape [batch_size]
        or a tensor whose shape matches `predictions`.
      scope: The scope for the operations performed in computing the loss.
  
    Returns:
      A scalar `Tensor` representing the loss value.
  
    Raises:
      ValueError: If the shape of `predictions` doesn't match that of `targets` or
        if the shape of `weight` is invalid.
    """
    with ops.op_scope([predictions, targets],
                      scope, "sum_of_pairwise_squares_loss") as scope:
      predictions.get_shape().assert_is_compatible_with(targets.get_shape())
      if weight is None:
        raise ValueError("`weight` cannot be None")
      predictions = math_ops.to_float(predictions)
      targets = math_ops.to_float(targets)
      weight = math_ops.to_float(ops.convert_to_tensor(weight))
  
      diffs = math_ops.sub(predictions, targets)
  
      # Need to verify here since the function doesn't use _compute_weighted_loss
      if diffs.get_shape().ndims is None:
        raise ValueError("diffs.get_shape().ndims cannot be None")
      if weight.get_shape().ndims is None:
        raise ValueError("weight.get_shape().ndims cannot be None")
  
      reduction_indices = list(range(1, diffs.get_shape().ndims))
  
      sum_squares_diff_per_batch = math_ops.reduce_sum(
          math_ops.square(diffs),
          reduction_indices=reduction_indices)
      num_present_per_batch = _num_present(diffs, weight, per_batch=True)
  
      term1 = 2.0 * _safe_div(sum_squares_diff_per_batch,
                              num_present_per_batch)
  
      sum_diff = math_ops.reduce_sum(diffs, reduction_indices=reduction_indices)
      term2 = 2.0 * _safe_div(math_ops.square(sum_diff),
                              math_ops.square(num_present_per_batch))
  
      loss = _scale_losses(term1 - term2, weight)
  
      mean_loss = math_ops.select(math_ops.reduce_sum(num_present_per_batch) > 0,
                                  loss,
                                  array_ops.zeros_like(loss),
                                  name="value")
      add_loss(mean_loss)
      return mean_loss
function_tokens: def sum_of_pairwise_squares ( predictions , targets , weight = 1.0 , scope = None ) : with ops . op_scope ( [ predictions , targets ] , scope , "sum_of_pairwise_squares_loss" ) as scope : predictions . get_shape ( ) . assert_is_compatible_with ( targets . get_shape ( ) ) if weight is None : raise ValueError ( "`weight` cannot be None" ) predictions = math_ops . to_float ( predictions ) targets = math_ops . to_float ( targets ) weight = math_ops . to_float ( ops . convert_to_tensor ( weight ) ) diffs = math_ops . sub ( predictions , targets ) # Need to verify here since the function doesn't use _compute_weighted_loss if diffs . get_shape ( ) . ndims is None : raise ValueError ( "diffs.get_shape().ndims cannot be None" ) if weight . get_shape ( ) . ndims is None : raise ValueError ( "weight.get_shape().ndims cannot be None" ) reduction_indices = list ( range ( 1 , diffs . get_shape ( ) . ndims ) ) sum_squares_diff_per_batch = math_ops . reduce_sum ( math_ops . square ( diffs ) , reduction_indices = reduction_indices ) num_present_per_batch = _num_present ( diffs , weight , per_batch = True ) term1 = 2.0 * _safe_div ( sum_squares_diff_per_batch , num_present_per_batch ) sum_diff = math_ops . reduce_sum ( diffs , reduction_indices = reduction_indices ) term2 = 2.0 * _safe_div ( math_ops . square ( sum_diff ) , math_ops . square ( num_present_per_batch ) ) loss = _scale_losses ( term1 - term2 , weight ) mean_loss = math_ops . select ( math_ops . reduce_sum ( num_present_per_batch ) > 0 , loss , array_ops . zeros_like ( loss ) , name = "value" ) add_loss ( mean_loss ) return mean_loss