I am not familiar with an evaluation function in pytorch tutorial. I would appreciate if you can direct me to it if it is relevant for what I want

I thought you’d been looking at the pytorch torchvision tutorial and it’s source code
https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html 1
The main training function
  

      github.com
  

  
    pytorch/vision/blob/master/references/detection/train.py#L203-L224 1



      
      
          for epoch in range(args.start_epoch, args.epochs):
              if args.distributed:
                  train_sampler.set_epoch(epoch)
              train_one_epoch(model, optimizer, data_loader, device, epoch, args.print_freq)
              lr_scheduler.step()
              if args.output_dir:
                  checkpoint = {
                      'model': model_without_ddp.state_dict(),
                      'optimizer': optimizer.state_dict(),
                      'lr_scheduler': lr_scheduler.state_dict(),
                      'args': args,
                      'epoch': epoch
                  }
                  utils.save_on_master(
                      checkpoint,
                      os.path.join(args.output_dir, 'model_{}.pth'.format(epoch)))
                  utils.save_on_master(
                      checkpoint,
                      os.path.join(args.output_dir, 'checkpoint.pth'))
          
      

    
  

  This file has been truncated. show original

  

  
    
    
  

  


The train_one_epoch piece

  

      github.com
  

  
    pytorch/vision/blob/master/references/detection/engine.py#L13-L55 1



      
      
          def train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq):
              model.train()
              metric_logger = utils.MetricLogger(delimiter="  ")
              metric_logger.add_meter('lr', utils.SmoothedValue(window_size=1, fmt='{value:.6f}'))
              header = 'Epoch: [{}]'.format(epoch)
          
          
    lr_scheduler = None
              if epoch == 0:
                  warmup_factor = 1. / 1000
                  warmup_iters = min(1000, len(data_loader) - 1)
          
          
        lr_scheduler = utils.warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor)
          
          
    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]
          
          
        loss_dict = model(images, targets)
          
          
        losses = sum(loss for loss in loss_dict.values())
      
    
  

  This file has been truncated. show original