mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	Fix logging
This commit is contained in:
		
							parent
							
								
									4bbe41f017
								
							
						
					
					
						commit
						4eb39b5c43
					
				| 
						 | 
					@ -480,6 +480,7 @@ class Errors:
 | 
				
			||||||
    E201 = ("Span index out of range.")
 | 
					    E201 = ("Span index out of range.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # TODO: fix numbering after merging develop into master
 | 
					    # TODO: fix numbering after merging develop into master
 | 
				
			||||||
 | 
					    E916 = ("Can't log score for '{name}' in table: not a valid score ({score_type})")
 | 
				
			||||||
    E917 = ("Received invalid value {value} for 'state_type' in "
 | 
					    E917 = ("Received invalid value {value} for 'state_type' in "
 | 
				
			||||||
            "TransitionBasedParser: only 'parser' or 'ner' are valid options.")
 | 
					            "TransitionBasedParser: only 'parser' or 'ner' are valid options.")
 | 
				
			||||||
    E918 = ("Received invalid value for vocab: {vocab} ({vocab_type}). Valid "
 | 
					    E918 = ("Received invalid value for vocab: {vocab} ({vocab_type}). Valid "
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,8 @@ def console_logger():
 | 
				
			||||||
    ) -> Tuple[Callable[[Dict[str, Any]], None], Callable]:
 | 
					    ) -> Tuple[Callable[[Dict[str, Any]], None], Callable]:
 | 
				
			||||||
        # we assume here that only components are enabled that should be trained & logged
 | 
					        # we assume here that only components are enabled that should be trained & logged
 | 
				
			||||||
        logged_pipes = nlp.pipe_names
 | 
					        logged_pipes = nlp.pipe_names
 | 
				
			||||||
        score_cols = list(nlp.config["training"]["score_weights"])
 | 
					        score_weights = nlp.config["training"]["score_weights"]
 | 
				
			||||||
 | 
					        score_cols = [col for col, value in score_weights.items() if value is not None]
 | 
				
			||||||
        score_widths = [max(len(col), 6) for col in score_cols]
 | 
					        score_widths = [max(len(col), 6) for col in score_cols]
 | 
				
			||||||
        loss_cols = [f"Loss {pipe}" for pipe in logged_pipes]
 | 
					        loss_cols = [f"Loss {pipe}" for pipe in logged_pipes]
 | 
				
			||||||
        loss_widths = [max(len(col), 8) for col in loss_cols]
 | 
					        loss_widths = [max(len(col), 8) for col in loss_cols]
 | 
				
			||||||
| 
						 | 
					@ -40,10 +41,15 @@ def console_logger():
 | 
				
			||||||
                ) from None
 | 
					                ) from None
 | 
				
			||||||
            scores = []
 | 
					            scores = []
 | 
				
			||||||
            for col in score_cols:
 | 
					            for col in score_cols:
 | 
				
			||||||
                score = float(info["other_scores"].get(col, 0.0))
 | 
					                score = info["other_scores"].get(col, 0.0)
 | 
				
			||||||
 | 
					                try:
 | 
				
			||||||
 | 
					                    score = float(score)
 | 
				
			||||||
                    if col != "speed":
 | 
					                    if col != "speed":
 | 
				
			||||||
                        score *= 100
 | 
					                        score *= 100
 | 
				
			||||||
                    scores.append("{0:.2f}".format(score))
 | 
					                    scores.append("{0:.2f}".format(score))
 | 
				
			||||||
 | 
					                except TypeError:
 | 
				
			||||||
 | 
					                    err = Errors.E916.format(name=col, score_type=type(score))
 | 
				
			||||||
 | 
					                    raise TypeError(err) from None
 | 
				
			||||||
            data = (
 | 
					            data = (
 | 
				
			||||||
                [info["epoch"], info["step"]]
 | 
					                [info["epoch"], info["step"]]
 | 
				
			||||||
                + losses
 | 
					                + losses
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user