original_docstring: 
            Train function of every epoch during train phase.
          
docstring: Train function of every epoch during train phase.
docstring_tokens: Train function of every epoch during train phase .
code: def __train(self):
          """
            Train function of every epoch during train phase.
          """
          self.det_net.train()
          start_time = time.time()
          # Adjust the learning rate after every epoch.
          self.configer.plus_one('epoch')
          self.scheduler.step(self.configer.get('epoch'))
  
          # data_tuple: (inputs, heatmap, maskmap, vecmap)
          for i, data_dict in enumerate(self.train_loader):
              if not self.configer.is_empty('lr', 'is_warm') and self.configer.get('lr', 'is_warm'):
                  self.warm_lr(len(self.train_loader))
  
              inputs = data_dict['img']
              batch_gt_bboxes = data_dict['bboxes']
              batch_gt_labels = data_dict['labels']
              # Change the data type.
              inputs = self.module_utilizer.to_device(inputs)
  
              self.data_time.update(time.time() - start_time)
              # Forward pass.
              feat_list, loc, cls = self.det_net(inputs)
  
              bboxes, labels = self.ssd_target_generator(feat_list, batch_gt_bboxes,
                                                         batch_gt_labels, [inputs.size(3), inputs.size(2)])
  
              bboxes, labels = self.module_utilizer.to_device(bboxes, labels)
              # Compute the loss of the train batch & backward.
              loss = self.det_loss(loc, bboxes, cls, labels)
  
              self.train_losses.update(loss.item(), inputs.size(0))
  
              self.optimizer.zero_grad()
              loss.backward()
              self.optimizer.step()
  
              # Update the vars of the train phase.
              self.batch_time.update(time.time() - start_time)
              start_time = time.time()
              self.configer.plus_one('iters')
  
              # Print the log info & reset the states.
              if self.configer.get('iters') % self.configer.get('solver', 'display_iter') == 0:
                  Log.info('Train Epoch: {0}\tTrain Iteration: {1}\t'
                           'Time {batch_time.sum:.3f}s / {2}iters, ({batch_time.avg:.3f})\t'
                           'Data load {data_time.sum:.3f}s / {2}iters, ({data_time.avg:3f})\n'
                           'Learning rate = {3}\tLoss = {loss.val:.8f} (ave = {loss.avg:.8f})\n'.format(
                      self.configer.get('epoch'), self.configer.get('iters'),
                      self.configer.get('solver', 'display_iter'),
                      self.scheduler.get_lr(), batch_time=self.batch_time,
                      data_time=self.data_time, loss=self.train_losses))
                  self.batch_time.reset()
                  self.data_time.reset()
                  self.train_losses.reset()
  
              # Check to val the current model.
              if self.val_loader is not None and \
                 (self.configer.get('iters')) % self.configer.get('solver', 'test_interval') == 0:
                  self.__val()
code_tokens: def __train ( self ) : self . det_net . train ( ) start_time = time . time ( ) self . configer . plus_one ( 'epoch' ) self . scheduler . step ( self . configer . get ( 'epoch' ) ) for i , data_dict in enumerate ( self . train_loader ) : if not self . configer . is_empty ( 'lr' , 'is_warm' ) and self . configer . get ( 'lr' , 'is_warm' ) : self . warm_lr ( len ( self . train_loader ) ) inputs = data_dict [ 'img' ] batch_gt_bboxes = data_dict [ 'bboxes' ] batch_gt_labels = data_dict [ 'labels' ] inputs = self . module_utilizer . to_device ( inputs ) self . data_time . update ( time . time ( ) - start_time ) feat_list , loc , cls = self . det_net ( inputs ) bboxes , labels = self . ssd_target_generator ( feat_list , batch_gt_bboxes , batch_gt_labels , [ inputs . size ( 3 ) , inputs . size ( 2 ) ] ) bboxes , labels = self . module_utilizer . to_device ( bboxes , labels ) loss = self . det_loss ( loc , bboxes , cls , labels ) self . train_losses . update ( loss . item ( ) , inputs . size ( 0 ) ) self . optimizer . zero_grad ( ) loss . backward ( ) self . optimizer . step ( ) self . batch_time . update ( time . time ( ) - start_time ) start_time = time . time ( ) self . configer . plus_one ( 'iters' ) if self . configer . get ( 'iters' ) % self . configer . get ( 'solver' , 'display_iter' ) == 0 : Log . info ( 'Train Epoch: {0}\tTrain Iteration: {1}\t' 'Time {batch_time.sum:.3f}s / {2}iters, ({batch_time.avg:.3f})\t' 'Data load {data_time.sum:.3f}s / {2}iters, ({data_time.avg:3f})\n' 'Learning rate = {3}\tLoss = {loss.val:.8f} (ave = {loss.avg:.8f})\n' . format ( self . configer . get ( 'epoch' ) , self . configer . get ( 'iters' ) , self . configer . get ( 'solver' , 'display_iter' ) , self . scheduler . get_lr ( ) , batch_time = self . batch_time , data_time = self . data_time , loss = self . train_losses ) ) self . batch_time . reset ( ) self . data_time . reset ( ) self . train_losses . reset ( ) if self . val_loader is not None and ( self . configer . get ( 'iters' ) ) % self . configer . get ( 'solver' , 'test_interval' ) == 0 : self . __val ( )
short_docstring: Train function of every epoch during train phase.
short_docstring_tokens: Train function of every epoch during train phase .
comment: """
            Train function of every epoch during train phase.
          """$SEP$# Adjust the learning rate after every epoch.$SEP$# data_tuple: (inputs, heatmap, maskmap, vecmap)$SEP$# Change the data type.$SEP$# Forward pass.$SEP$# Compute the loss of the train batch & backward.$SEP$# Update the vars of the train phase.$SEP$# Print the log info & reset the states.$SEP$# Check to val the current model.