|  |  |  | @ -114,6 +114,12 @@ def train(hyp, tb_writer, opt, device): | 
			
		
	
		
			
				
					|  |  |  |  |     print('Optimizer groups: %g .bias, %g conv.weight, %g other' % (len(pg2), len(pg1), len(pg0))) | 
			
		
	
		
			
				
					|  |  |  |  |     del pg0, pg1, pg2 | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |     # Scheduler https://arxiv.org/pdf/1812.01187.pdf | 
			
		
	
		
			
				
					|  |  |  |  |     lf = lambda x: (((1 + math.cos(x * math.pi / epochs)) / 2) ** 1.0) * 0.8 + 0.2  # cosine | 
			
		
	
		
			
				
					|  |  |  |  |     scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf) | 
			
		
	
		
			
				
					|  |  |  |  |     # https://discuss.pytorch.org/t/a-problem-occured-when-resuming-an-optimizer/28822 | 
			
		
	
		
			
				
					|  |  |  |  |     # plot_lr_scheduler(optimizer, scheduler, epochs) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     # Load Model | 
			
		
	
		
			
				
					|  |  |  |  |     with torch_distributed_zero_first(rank): | 
			
		
	
		
			
				
					|  |  |  |  |         google_utils.attempt_download(weights) | 
			
		
	
	
		
			
				
					|  |  |  | @ -158,12 +164,6 @@ def train(hyp, tb_writer, opt, device): | 
			
		
	
		
			
				
					|  |  |  |  |     if mixed_precision: | 
			
		
	
		
			
				
					|  |  |  |  |         model, optimizer = amp.initialize(model, optimizer, opt_level='O1', verbosity=0) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     # Scheduler https://arxiv.org/pdf/1812.01187.pdf | 
			
		
	
		
			
				
					|  |  |  |  |     lf = lambda x: (((1 + math.cos(x * math.pi / epochs)) / 2) ** 1.0) * 0.8 + 0.2  # cosine | 
			
		
	
		
			
				
					|  |  |  |  |     scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf) | 
			
		
	
		
			
				
					|  |  |  |  |     # https://discuss.pytorch.org/t/a-problem-occured-when-resuming-an-optimizer/28822 | 
			
		
	
		
			
				
					|  |  |  |  |     # plot_lr_scheduler(optimizer, scheduler, epochs) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     # DP mode | 
			
		
	
		
			
				
					|  |  |  |  |     if device.type != 'cpu' and rank == -1 and torch.cuda.device_count() > 1: | 
			
		
	
		
			
				
					|  |  |  |  |         model = torch.nn.DataParallel(model) | 
			
		
	
	
		
			
				
					|  |  |  | 
 |