mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	always return losses
This commit is contained in:
		
							parent
							
								
									1f49300862
								
							
						
					
					
						commit
						0aa8851878
					
				|  | @ -195,7 +195,7 @@ class Tagger(TrainablePipe): | |||
|         validate_examples(examples, "Tagger.update") | ||||
|         if not any(len(eg.predicted) if eg.predicted else 0 for eg in examples): | ||||
|             # Handle cases where there are no tokens in any docs. | ||||
|             return | ||||
|             return losses | ||||
|         set_dropout_rate(self.model, drop) | ||||
|         tag_scores, bp_tag_scores = self.model.begin_update([eg.predicted for eg in examples]) | ||||
|         for sc in tag_scores: | ||||
|  | @ -233,7 +233,7 @@ class Tagger(TrainablePipe): | |||
|             return | ||||
|         if not any(len(doc) for doc in docs): | ||||
|             # Handle cases where there are no tokens in any docs. | ||||
|             return | ||||
|             return losses | ||||
|         set_dropout_rate(self.model, drop) | ||||
|         guesses, backprop = self.model.begin_update(docs) | ||||
|         target = self._rehearsal_model(examples) | ||||
|  | @ -243,6 +243,7 @@ class Tagger(TrainablePipe): | |||
|         if losses is not None: | ||||
|             losses.setdefault(self.name, 0.0) | ||||
|             losses[self.name] += (gradient**2).sum() | ||||
|         return losses | ||||
| 
 | ||||
|     def get_loss(self, examples, scores): | ||||
|         """Find the loss and gradient of loss for the batch of documents and | ||||
|  |  | |||
|  | @ -116,7 +116,7 @@ cdef class TrainablePipe(Pipe): | |||
|         validate_examples(examples, "TrainablePipe.update") | ||||
|         if not any(len(eg.predicted) if eg.predicted else 0 for eg in examples): | ||||
|             # Handle cases where there are no tokens in any docs. | ||||
|             return | ||||
|             return losses | ||||
|         set_dropout_rate(self.model, drop) | ||||
|         scores, bp_scores = self.model.begin_update([eg.predicted for eg in examples]) | ||||
|         loss, d_scores = self.get_loss(examples, scores) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user