src/pose_net.py
def eval_error_distance(self):
        """Evaluation on validation set. Distance with the target spacecraft is also returned for each prediction"""
        phase = 'valid'

        loop = tqdm(self.dataloader[phase], desc="Evaluation by distance", file=sys.stdout,
                    bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}')

        ori_error = []
        pos_error = []
        distance = []
        for inputs, targets in loop:

            # Send inputs and targets tu GPU memory if device is CUDA                    
            inputs = inputs.to(self.config.DEVICE)
            targets['ori'], targets['pos'] = targets['ori'].to(self.config.DEVICE), \
                                             targets['pos'].to(self.config.DEVICE)

            with torch.set_grad_enabled(False):

                ori, pos = self.predict(inputs, phase)

            if self.config.ORI_TYPE == 'Classification':
                ori, _ = decode_ori_batch(ori, self.config.B)

            dist = torch.linalg.norm(targets['pos'], dim=1)

            pos_err = torch.linalg.norm(targets['pos'] - pos, dim=1)

            if self.config.ORI_TYPE == 'Regression':
                inter_sum = torch.abs(torch.sum(ori * targets['ori'], dim=1))
            else:
                inter_sum = torch.abs(torch.sum(ori * targets['ori_original'], dim=1))

            # Scaling down intermediate sum. See get_score function for more details
            if True in inter_sum[inter_sum > 1.01]:
                raise ValueError('Error computing orientation score intermediate sum')
            inter_sum[inter_sum > 1] = 1

            ori_err = 2 * torch.arccos(inter_sum) * 180 / np.pi

            distance.extend(dist.tolist())
            ori_error.extend(ori_err.tolist())
            pos_error.extend(pos_err.tolist())

        return ori_error, pos_error, distance
Evaluation on validation set. Distance with the target spacecraft is also returned for each prediction
Evaluation on validation set. Distance with the target spacecraft is also returned for each prediction
Evaluation on validation set . Distance with the target spacecraft is also returned for each prediction
def eval_error_distance(self):
        phase = 'valid'
        loop = tqdm(self.dataloader[phase], desc="Evaluation by distance", file=sys.stdout,
                    bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}')
        ori_error = []
        pos_error = []
        distance = []
        for inputs, targets in loop:
            inputs = inputs.to(self.config.DEVICE)
            targets['ori'], targets['pos'] = targets['ori'].to(self.config.DEVICE), \
                                             targets['pos'].to(self.config.DEVICE)
            with torch.set_grad_enabled(False):
                ori, pos = self.predict(inputs, phase)
            if self.config.ORI_TYPE == 'Classification':
                ori, _ = decode_ori_batch(ori, self.config.B)
            dist = torch.linalg.norm(targets['pos'], dim=1)
            pos_err = torch.linalg.norm(targets['pos'] - pos, dim=1)
            if self.config.ORI_TYPE == 'Regression':
                inter_sum = torch.abs(torch.sum(ori * targets['ori'], dim=1))
            else:
                inter_sum = torch.abs(torch.sum(ori * targets['ori_original'], dim=1))
            if True in inter_sum[inter_sum > 1.01]:
                raise ValueError('Error computing orientation score intermediate sum')
            inter_sum[inter_sum > 1] = 1
            ori_err = 2 * torch.arccos(inter_sum) * 180 / np.pi
            distance.extend(dist.tolist())
            ori_error.extend(ori_err.tolist())
            pos_error.extend(pos_err.tolist())
        return ori_error, pos_error, distance
def eval_error_distance ( self ) : phase = 'valid' loop = tqdm ( self . dataloader [ phase ] , desc = "Evaluation by distance" , file = sys . stdout , bar_format = '{l_bar}{bar:10}{r_bar}{bar:-10b}' ) ori_error = [ ] pos_error = [ ] distance = [ ] for inputs , targets in loop : inputs = inputs . to ( self . config . DEVICE ) targets [ 'ori' ] , targets [ 'pos' ] = targets [ 'ori' ] . to ( self . config . DEVICE ) , targets [ 'pos' ] . to ( self . config . DEVICE ) with torch . set_grad_enabled ( False ) : ori , pos = self . predict ( inputs , phase ) if self . config . ORI_TYPE == 'Classification' : ori , _ = decode_ori_batch ( ori , self . config . B ) dist = torch . linalg . norm ( targets [ 'pos' ] , dim = 1 ) pos_err = torch . linalg . norm ( targets [ 'pos' ] - pos , dim = 1 ) if self . config . ORI_TYPE == 'Regression' : inter_sum = torch . abs ( torch . sum ( ori * targets [ 'ori' ] , dim = 1 ) ) else : inter_sum = torch . abs ( torch . sum ( ori * targets [ 'ori_original' ] , dim = 1 ) ) if True in inter_sum [ inter_sum > 1.01 ] : raise ValueError ( 'Error computing orientation score intermediate sum' ) inter_sum [ inter_sum > 1 ] = 1 ori_err = 2 * torch . arccos ( inter_sum ) * 180 / np . pi distance . extend ( dist . tolist ( ) ) ori_error . extend ( ori_err . tolist ( ) ) pos_error . extend ( pos_err . tolist ( ) ) return ori_error , pos_error , distance
Evaluation on validation set.
Evaluation on validation set .
"""Evaluation on validation set. Distance with the target spacecraft is also returned for each prediction""" # Send inputs and targets tu GPU memory if device is CUDA                     # Scaling down intermediate sum. See get_score function for more details
self