somehow that the hard negtive sample is also needed to let the network knows the net better ,but in the code
  

      github.com
  

  
    pytorch/vision/blob/main/references/detection/engine.py#L27



      
      
          
          
lr_scheduler = None
          if epoch == 0:
              warmup_factor = 1.0 / 1000
              warmup_iters = min(1000, len(data_loader) - 1)
          
          
    lr_scheduler = torch.optim.lr_scheduler.LinearLR(
                  optimizer, start_factor=warmup_factor, total_iters=warmup_iters
              )
          
          
for images, targets in metric_logger.log_every(data_loader, print_freq, header):
              images = list(image.to(device) for image in images)
              targets = [{k: v.to(device) for k, v in t.items()} for t in targets]
              with torch.cuda.amp.autocast(enabled=scaler is not None):
                  loss_dict = model(images, targets)
                  losses = sum(loss for loss in loss_dict.values())
          
          
    # reduce losses over all GPUs for logging purposes
              loss_dict_reduced = utils.reduce_dict(loss_dict)
              losses_reduced = sum(loss for loss in loss_dict_reduced.values())
          
      

    
  


  

  
    
    
  

  


‘’‘for images, targets in metric_logger.log_every(data_loader, print_freq, header):
images = list(image.to(device) for image in images)
targets = [{k: v.to(device) for k, v in t.items()} for t in targets]
with torch.cuda.amp.autocast(enabled=scaler is not None):
loss_dict = model(images, targets)
losses = sum(loss for loss in loss_dict.values())‘’’
it could not handle if the target is None