def _neg_loss(self, pred, gt):
    ' Modified focal loss. Exactly the same as CornerNet.\n            Runs faster and costs a little bit more memory\n            Arguments:\n              pred (batch x c x h x w)\n              gt_regr (batch x c x h x w)\n        '
    pos_inds = gt.eq(1).float()
    neg_inds = gt.lt(1).float()
    neg_weights = torch.pow((1 - gt), 4)
    loss = 0
    pos_loss = ((torch.log(pred) * torch.pow((1 - pred), 2)) * pos_inds)
    neg_loss = (((torch.log((1 - pred)) * torch.pow(pred, 2)) * neg_weights) * neg_inds)
    num_pos = pos_inds.float().sum()
    pos_loss = pos_loss.sum()
    neg_loss = neg_loss.sum()
    if (num_pos == 0):
        loss = (loss - neg_loss)
    else:
        loss = (loss - ((pos_loss + neg_loss) / num_pos))
    return loss
Modified focal loss. Exactly the same as CornerNet.
Runs faster and costs a little bit more memory
Arguments:
  pred (batch x c x h x w)
  gt_regr (batch x c x h x w)
def _neg_loss(self, pred, gt):
    ' Modified focal loss. Exactly the same as CornerNet.\n            Runs faster and costs a little bit more memory\n            Arguments:\n              pred (batch x c x h x w)\n              gt_regr (batch x c x h x w)\n        '
    pos_inds = gt.eq(1).float()
    neg_inds = gt.lt(1).float()
    neg_weights = torch.pow((1 - gt), 4)
    loss = 0
    pos_loss = ((torch.log(pred) * torch.pow((1 - pred), 2)) * pos_inds)
    neg_loss = (((torch.log((1 - pred)) * torch.pow(pred, 2)) * neg_weights) * neg_inds)
    num_pos = pos_inds.float().sum()
    pos_loss = pos_loss.sum()
    neg_loss = neg_loss.sum()
    if (num_pos == 0):
        loss = (loss - neg_loss)
    else:
        loss = (loss - ((pos_loss + neg_loss) / num_pos))
    return loss