Translocations_Detector/models/detr.py
def loss_cardinality(self, outputs, targets, indices, num_segments):
        """ Compute the cardinality error, ie the absolute error in the number of predicted non-empty segments
        This is not really a loss, it is intended for logging purposes only. It doesn't propagate gradients
        """
        pred_logits = outputs['pred_logits']
        device = pred_logits.device
        tgt_lengths = torch.as_tensor([len(v["labels"]) for v in targets], device=device)
        # Count the number of predictions that are NOT "no-translocation" (which is the last class)
        card_pred = (pred_logits.argmax(-1) != pred_logits.shape[-1] - 1).sum(1)
        card_err = F.l1_loss(card_pred.float(), tgt_lengths.float())
        losses = {'cardinality_error': card_err}
        return losses
 Compute the cardinality error, ie the absolute error in the number of predicted non-empty segments
        This is not really a loss, it is intended for logging purposes only. It doesn't propagate gradients
        
Compute the cardinality error, ie the absolute error in the number of predicted non-empty segments
This is not really a loss, it is intended for logging purposes only. It doesn't propagate gradients
Compute the cardinality error ie the absolute error in the number of predicted non - empty segments This is not really a loss it is intended for logging purposes only . It doesn ' t propagate gradients
def loss_cardinality(self, outputs, targets, indices, num_segments):
        pred_logits = outputs['pred_logits']
        device = pred_logits.device
        tgt_lengths = torch.as_tensor([len(v["labels"]) for v in targets], device=device)
        card_pred = (pred_logits.argmax(-1) != pred_logits.shape[-1] - 1).sum(1)
        card_err = F.l1_loss(card_pred.float(), tgt_lengths.float())
        losses = {'cardinality_error': card_err}
        return losses
def loss_cardinality ( self , outputs , targets , indices , num_segments ) : pred_logits = outputs [ 'pred_logits' ] device = pred_logits . device tgt_lengths = torch . as_tensor ( [ len ( v [ "labels" ] ) for v in targets ] , device = device ) card_pred = ( pred_logits . argmax ( - 1 ) != pred_logits . shape [ - 1 ] - 1 ) . sum ( 1 ) card_err = F . l1_loss ( card_pred . float ( ) , tgt_lengths . float ( ) ) losses = { 'cardinality_error' : card_err } return losses
Compute the cardinality error, ie the absolute error in the number of predicted non-empty segments
This is not really a loss, it is intended for logging purposes only.
Compute the cardinality error ie the absolute error in the number of predicted non - empty segments This is not really a loss it is intended for logging purposes only .
""" Compute the cardinality error, ie the absolute error in the number of predicted non-empty segments
        This is not really a loss, it is intended for logging purposes only. It doesn't propagate gradients
        """ # Count the number of predictions that are NOT "no-translocation" (which is the last class)
self
outputs
targets
indices
num_segments