loss/set_criterion.py
def loss_labels(self, outputs, targets, indices, num_boxes, log=True):
        """Classification loss (NLL)
        targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
        """
        assert 'human_pred_logits' in outputs
        assert 'object_pred_logits' in outputs
        assert 'action_pred_logits' in outputs
        human_src_logits = outputs['human_pred_logits']
        object_src_logits = outputs['object_pred_logits']
        action_src_logits = outputs['action_pred_logits']

        idx = self._get_src_permutation_idx(indices)

        human_target_classes_o = torch.cat(
            [t["human_labels"][J] for t, (_, J) in zip(targets, indices)])
        object_target_classes_o = torch.cat(
            [t["object_labels"][J] for t, (_, J) in zip(targets, indices)])
        action_target_classes_o = torch.cat(
            [t["action_labels"][J] for t, (_, J) in zip(targets, indices)])

        human_target_classes = torch.full(human_src_logits.shape[:2], num_humans,
                                          dtype=torch.int64, device=human_src_logits.device)
        human_target_classes[idx] = human_target_classes_o

        object_target_classes = torch.full(object_src_logits.shape[:2], self.num_classes,
                                           dtype=torch.int64, device=object_src_logits.device)
        object_target_classes[idx] = object_target_classes_o

        action_target_classes = torch.full(action_src_logits.shape[:2], self.num_actions,
                                           dtype=torch.int64, device=action_src_logits.device)
        action_target_classes[idx] = action_target_classes_o

        human_loss_ce = F.cross_entropy(human_src_logits.transpose(1, 2),
                                        human_target_classes, self.human_empty_weight)
        object_loss_ce = F.cross_entropy(object_src_logits.transpose(1, 2),
                                         object_target_classes, self.object_empty_weight)
        action_loss_ce = F.cross_entropy(action_src_logits.transpose(1, 2),
                                         action_target_classes, self.action_empty_weight)
        loss_ce = human_loss_ce + object_loss_ce + 2 * action_loss_ce
        losses = {
            'loss_ce': loss_ce,
            'human_loss_ce': human_loss_ce,
            'object_loss_ce': object_loss_ce,
            'action_loss_ce': action_loss_ce
        }

        if log:
            losses['class_error'] = 100 - \
                accuracy(action_src_logits[idx], action_target_classes_o)[0]
        return losses
Classification loss (NLL)
        targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
        
Classification loss (NLL)
targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
Classification loss ( NLL ) targets dicts must contain the key " labels " containing a tensor of dim [ nb_target_boxes ]
def loss_labels(self, outputs, targets, indices, num_boxes, log=True):
        assert 'human_pred_logits' in outputs
        assert 'object_pred_logits' in outputs
        assert 'action_pred_logits' in outputs
        human_src_logits = outputs['human_pred_logits']
        object_src_logits = outputs['object_pred_logits']
        action_src_logits = outputs['action_pred_logits']
        idx = self._get_src_permutation_idx(indices)
        human_target_classes_o = torch.cat(
            [t["human_labels"][J] for t, (_, J) in zip(targets, indices)])
        object_target_classes_o = torch.cat(
            [t["object_labels"][J] for t, (_, J) in zip(targets, indices)])
        action_target_classes_o = torch.cat(
            [t["action_labels"][J] for t, (_, J) in zip(targets, indices)])
        human_target_classes = torch.full(human_src_logits.shape[:2], num_humans,
                                          dtype=torch.int64, device=human_src_logits.device)
        human_target_classes[idx] = human_target_classes_o
        object_target_classes = torch.full(object_src_logits.shape[:2], self.num_classes,
                                           dtype=torch.int64, device=object_src_logits.device)
        object_target_classes[idx] = object_target_classes_o
        action_target_classes = torch.full(action_src_logits.shape[:2], self.num_actions,
                                           dtype=torch.int64, device=action_src_logits.device)
        action_target_classes[idx] = action_target_classes_o
        human_loss_ce = F.cross_entropy(human_src_logits.transpose(1, 2),
                                        human_target_classes, self.human_empty_weight)
        object_loss_ce = F.cross_entropy(object_src_logits.transpose(1, 2),
                                         object_target_classes, self.object_empty_weight)
        action_loss_ce = F.cross_entropy(action_src_logits.transpose(1, 2),
                                         action_target_classes, self.action_empty_weight)
        loss_ce = human_loss_ce + object_loss_ce + 2 * action_loss_ce
        losses = {
            'loss_ce': loss_ce,
            'human_loss_ce': human_loss_ce,
            'object_loss_ce': object_loss_ce,
            'action_loss_ce': action_loss_ce
        }
        if log:
            losses['class_error'] = 100 - \
                accuracy(action_src_logits[idx], action_target_classes_o)[0]
        return losses
def loss_labels ( self , outputs , targets , indices , num_boxes , log = True ) : assert 'human_pred_logits' in outputs assert 'object_pred_logits' in outputs assert 'action_pred_logits' in outputs human_src_logits = outputs [ 'human_pred_logits' ] object_src_logits = outputs [ 'object_pred_logits' ] action_src_logits = outputs [ 'action_pred_logits' ] idx = self . _get_src_permutation_idx ( indices ) human_target_classes_o = torch . cat ( [ t [ "human_labels" ] [ J ] for t , ( _ , J ) in zip ( targets , indices ) ] ) object_target_classes_o = torch . cat ( [ t [ "object_labels" ] [ J ] for t , ( _ , J ) in zip ( targets , indices ) ] ) action_target_classes_o = torch . cat ( [ t [ "action_labels" ] [ J ] for t , ( _ , J ) in zip ( targets , indices ) ] ) human_target_classes = torch . full ( human_src_logits . shape [ : 2 ] , num_humans , dtype = torch . int64 , device = human_src_logits . device ) human_target_classes [ idx ] = human_target_classes_o object_target_classes = torch . full ( object_src_logits . shape [ : 2 ] , self . num_classes , dtype = torch . int64 , device = object_src_logits . device ) object_target_classes [ idx ] = object_target_classes_o action_target_classes = torch . full ( action_src_logits . shape [ : 2 ] , self . num_actions , dtype = torch . int64 , device = action_src_logits . device ) action_target_classes [ idx ] = action_target_classes_o human_loss_ce = F . cross_entropy ( human_src_logits . transpose ( 1 , 2 ) , human_target_classes , self . human_empty_weight ) object_loss_ce = F . cross_entropy ( object_src_logits . transpose ( 1 , 2 ) , object_target_classes , self . object_empty_weight ) action_loss_ce = F . cross_entropy ( action_src_logits . transpose ( 1 , 2 ) , action_target_classes , self . action_empty_weight ) loss_ce = human_loss_ce + object_loss_ce + 2 * action_loss_ce losses = { 'loss_ce' : loss_ce , 'human_loss_ce' : human_loss_ce , 'object_loss_ce' : object_loss_ce , 'action_loss_ce' : action_loss_ce } if log : losses [ 'class_error' ] = 100 - accuracy ( action_src_logits [ idx ] , action_target_classes_o ) [ 0 ] return losses
Classification loss (NLL)
targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
Classification loss ( NLL ) targets dicts must contain the key " labels " containing a tensor of dim [ nb_target_boxes ]
"""Classification loss (NLL)
        targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
        """
self
outputs
targets
indices
num_boxes
log