(self, prediction_tensor, target_tensor, weights=None)
return anchorwise_smooth_l1norm
Compute loss function.

    Args:
      prediction_tensor: A float tensor of shape [batch_size, num_anchors,
        code_size] representing the (encoded) predicted locations of objects.
      target_tensor: A float tensor of shape [batch_size, num_anchors,
        code_size] representing the regression targets
      weights: a float tensor of shape [batch_size, num_anchors]

    Returns:
      loss: a float tensor of shape [batch_size, num_anchors] tensor
        representing the value of the loss function.
Compute loss function.
Compute loss function .
def _compute_loss(self, prediction_tensor, target_tensor, weights=None):
    """Compute loss function.

    Args:
      prediction_tensor: A float tensor of shape [batch_size, num_anchors,
        code_size] representing the (encoded) predicted locations of objects.
      target_tensor: A float tensor of shape [batch_size, num_anchors,
        code_size] representing the regression targets
      weights: a float tensor of shape [batch_size, num_anchors]

    Returns:
      loss: a float tensor of shape [batch_size, num_anchors] tensor
        representing the value of the loss function.
    """
    diff = prediction_tensor - target_tensor
    if self._code_weights is not None:
      code_weights = self._code_weights.type_as(prediction_tensor).to(target_tensor.device)
      diff = code_weights.view(1, 1, -1) * diff
    abs_diff = torch.abs(diff)
    abs_diff_lt_1 = torch.le(abs_diff, 1 / (self._sigma**2)).type_as(abs_diff)
    loss = abs_diff_lt_1 * 0.5 * torch.pow(abs_diff * self._sigma, 2) \
      + (abs_diff - 0.5 / (self._sigma**2)) * (1. - abs_diff_lt_1)
    if self._codewise:
      anchorwise_smooth_l1norm = loss
      if weights is not None:
        anchorwise_smooth_l1norm *= weights.unsqueeze(-1)
    else:
      anchorwise_smooth_l1norm = torch.sum(loss, 2)#  * weights
      if weights is not None:
        anchorwise_smooth_l1norm *= weights
    return anchorwise_smooth_l1norm
def _compute_loss ( self , prediction_tensor , target_tensor , weights = None ) : diff = prediction_tensor - target_tensor if self . _code_weights is not None : code_weights = self . _code_weights . type_as ( prediction_tensor ) . to ( target_tensor . device ) diff = code_weights . view ( 1 , 1 , - 1 ) * diff abs_diff = torch . abs ( diff ) abs_diff_lt_1 = torch . le ( abs_diff , 1 / ( self . _sigma ** 2 ) ) . type_as ( abs_diff ) loss = abs_diff_lt_1 * 0.5 * torch . pow ( abs_diff * self . _sigma , 2 ) + ( abs_diff - 0.5 / ( self . _sigma ** 2 ) ) * ( 1. - abs_diff_lt_1 ) if self . _codewise : anchorwise_smooth_l1norm = loss if weights is not None : anchorwise_smooth_l1norm *= weights . unsqueeze ( - 1 ) else : anchorwise_smooth_l1norm = torch . sum ( loss , 2 ) #  * weights if weights is not None : anchorwise_smooth_l1norm *= weights return anchorwise_smooth_l1norm