original_docstring: 
            Validation function during the train phase.
          
docstring: Validation function during the train phase.
docstring_tokens: Validation function during the train phase .
code: def __val(self):
          """
            Validation function during the train phase.
          """
          self.det_net.eval()
          start_time = time.time()
          with torch.no_grad():
              for j, data_dict in enumerate(self.val_loader):
                  inputs = data_dict['img']
                  batch_gt_bboxes = data_dict['bboxes']
                  batch_gt_labels = data_dict['labels']
                  inputs = self.module_utilizer.to_device(inputs)
                  input_size = [inputs.size(3), inputs.size(2)]
                  # Forward pass.
                  feat_list, loc, cls = self.det_net(inputs)
                  bboxes, labels = self.ssd_target_generator(feat_list, batch_gt_bboxes,
                                                             batch_gt_labels, input_size)
  
                  bboxes, labels = self.module_utilizer.to_device(bboxes, labels)
                  # Compute the loss of the val batch.
                  loss = self.det_loss(loc, bboxes, cls, labels)
                  self.val_losses.update(loss.item(), inputs.size(0))
  
                  batch_detections = SingleShotDetectorTest.decode(loc, cls,
                                                                   self.ssd_priorbox_layer(feat_list, input_size),
                                                                   self.configer, input_size)
                  batch_pred_bboxes = self.__get_object_list(batch_detections)
                  # batch_pred_bboxes = self._get_gt_object_list(batch_gt_bboxes, batch_gt_labels)
                  self.det_running_score.update(batch_pred_bboxes, batch_gt_bboxes, batch_gt_labels)
  
                  # Update the vars of the val phase.
                  self.batch_time.update(time.time() - start_time)
                  start_time = time.time()
  
              self.module_utilizer.save_net(self.det_net, save_mode='iters')
              # Print the log info & reset the states.
              Log.info(
                  'Test Time {batch_time.sum:.3f}s, ({batch_time.avg:.3f})\t'
                  'Loss {loss.avg:.8f}\n'.format(
                      batch_time=self.batch_time, loss=self.val_losses))
              Log.info('Val mAP: {}'.format(self.det_running_score.get_mAP()))
              self.det_running_score.reset()
              self.batch_time.reset()
              self.val_losses.reset()
              self.det_net.train()
code_tokens: def __val ( self ) : self . det_net . eval ( ) start_time = time . time ( ) with torch . no_grad ( ) : for j , data_dict in enumerate ( self . val_loader ) : inputs = data_dict [ 'img' ] batch_gt_bboxes = data_dict [ 'bboxes' ] batch_gt_labels = data_dict [ 'labels' ] inputs = self . module_utilizer . to_device ( inputs ) input_size = [ inputs . size ( 3 ) , inputs . size ( 2 ) ] feat_list , loc , cls = self . det_net ( inputs ) bboxes , labels = self . ssd_target_generator ( feat_list , batch_gt_bboxes , batch_gt_labels , input_size ) bboxes , labels = self . module_utilizer . to_device ( bboxes , labels ) loss = self . det_loss ( loc , bboxes , cls , labels ) self . val_losses . update ( loss . item ( ) , inputs . size ( 0 ) ) batch_detections = SingleShotDetectorTest . decode ( loc , cls , self . ssd_priorbox_layer ( feat_list , input_size ) , self . configer , input_size ) batch_pred_bboxes = self . __get_object_list ( batch_detections ) self . det_running_score . update ( batch_pred_bboxes , batch_gt_bboxes , batch_gt_labels ) self . batch_time . update ( time . time ( ) - start_time ) start_time = time . time ( ) self . module_utilizer . save_net ( self . det_net , save_mode = 'iters' ) Log . info ( 'Test Time {batch_time.sum:.3f}s, ({batch_time.avg:.3f})\t' 'Loss {loss.avg:.8f}\n' . format ( batch_time = self . batch_time , loss = self . val_losses ) ) Log . info ( 'Val mAP: {}' . format ( self . det_running_score . get_mAP ( ) ) ) self . det_running_score . reset ( ) self . batch_time . reset ( ) self . val_losses . reset ( ) self . det_net . train ( )
short_docstring: Validation function during the train phase.
short_docstring_tokens: Validation function during the train phase .
comment: """
            Validation function during the train phase.
          """$SEP$# Forward pass.$SEP$# Compute the loss of the val batch.$SEP$# batch_pred_bboxes = self._get_gt_object_list(batch_gt_bboxes, batch_gt_labels)$SEP$# Update the vars of the val phase.$SEP$# Print the log info & reset the states.