mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	Fix patience for identical scores (#7250)
* Fix patience for identical scores Fix training patience so that the earliest best step is chosen for identical max scores. * Restore break, remove print * Explicitly define best_step for clarity
This commit is contained in:
		
							parent
							
								
									dfb23a419e
								
							
						
					
					
						commit
						97bcf2ae3a
					
				|  | @ -230,7 +230,10 @@ def train_while_improving( | |||
|         if is_best_checkpoint is not None: | ||||
|             losses = {} | ||||
|         # Stop if no improvement in `patience` updates (if specified) | ||||
|         best_score, best_step = max(results) | ||||
|         # Negate step value so that the earliest best step is chosen for the | ||||
|         # same score, i.e. (1.0, 100) is chosen over (1.0, 200) | ||||
|         best_result = max((r_score, -r_step) for r_score, r_step in results) | ||||
|         best_step = -best_result[1] | ||||
|         if patience and (step - best_step) >= patience: | ||||
|             break | ||||
|         # Stop if we've exhausted our max steps (if specified) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user