(self, anchors, objectness, box_regression, targets)
return objectness_loss, box_loss
Arguments:
            anchors (list[BoxList])
            objectness (list[Tensor])
            box_regression (list[Tensor])
            targets (list[BoxList])

        Returns:
            objectness_loss (Tensor)
            box_loss (Tensor
Arguments:
            anchors (list[BoxList])
            objectness (list[Tensor])
            box_regression (list[Tensor])
            targets (list[BoxList])
Arguments : anchors ( list [ BoxList ] ) objectness ( list [ Tensor ] ) box_regression ( list [ Tensor ] ) targets ( list [ BoxList ] )
def __call__(self, anchors, objectness, box_regression, targets):
        """
        Arguments:
            anchors (list[BoxList])
            objectness (list[Tensor])
            box_regression (list[Tensor])
            targets (list[BoxList])

        Returns:
            objectness_loss (Tensor)
            box_loss (Tensor
        """
        anchors = [cat_boxlist(anchors_per_image) for anchors_per_image in anchors]
        labels, regression_targets = self.prepare_targets(anchors, targets)
        sampled_pos_inds, sampled_neg_inds = self.fg_bg_sampler(labels)
        sampled_pos_inds = torch.nonzero(torch.cat(sampled_pos_inds, dim=0)).squeeze(1)
        sampled_neg_inds = torch.nonzero(torch.cat(sampled_neg_inds, dim=0)).squeeze(1)

        sampled_inds = torch.cat([sampled_pos_inds, sampled_neg_inds], dim=0)

        objectness, box_regression = \
                concat_box_prediction_layers(objectness, box_regression)

        objectness = objectness.squeeze()

        labels = torch.cat(labels, dim=0)
        regression_targets = torch.cat(regression_targets, dim=0)

        box_loss = smooth_l1_loss(
            box_regression[sampled_pos_inds],
            regression_targets[sampled_pos_inds],
            beta=1.0 / 9,
            size_average=False,
        ) / (sampled_inds.numel())

        objectness_loss = F.binary_cross_entropy_with_logits(
            objectness[sampled_inds], labels[sampled_inds]
        )

        return objectness_loss, box_loss
def __call__ ( self , anchors , objectness , box_regression , targets ) : anchors = [ cat_boxlist ( anchors_per_image ) for anchors_per_image in anchors ] labels , regression_targets = self . prepare_targets ( anchors , targets ) sampled_pos_inds , sampled_neg_inds = self . fg_bg_sampler ( labels ) sampled_pos_inds = torch . nonzero ( torch . cat ( sampled_pos_inds , dim = 0 ) ) . squeeze ( 1 ) sampled_neg_inds = torch . nonzero ( torch . cat ( sampled_neg_inds , dim = 0 ) ) . squeeze ( 1 ) sampled_inds = torch . cat ( [ sampled_pos_inds , sampled_neg_inds ] , dim = 0 ) objectness , box_regression = concat_box_prediction_layers ( objectness , box_regression ) objectness = objectness . squeeze ( ) labels = torch . cat ( labels , dim = 0 ) regression_targets = torch . cat ( regression_targets , dim = 0 ) box_loss = smooth_l1_loss ( box_regression [ sampled_pos_inds ] , regression_targets [ sampled_pos_inds ] , beta = 1.0 / 9 , size_average = False , ) / ( sampled_inds . numel ( ) ) objectness_loss = F . binary_cross_entropy_with_logits ( objectness [ sampled_inds ] , labels [ sampled_inds ] ) return objectness_loss , box_loss