mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-30 23:47:31 +03:00 
			
		
		
		
	Don't call begin_training if updating new model (see #3059) [ci skip]
This commit is contained in:
		
							parent
							
								
									6f1438b5d9
								
							
						
					
					
						commit
						c9a89bba50
					
				|  | @ -56,7 +56,10 @@ def main(model=None, output_dir=None, n_iter=100): | ||||||
|     # get names of other pipes to disable them during training |     # get names of other pipes to disable them during training | ||||||
|     other_pipes = [pipe for pipe in nlp.pipe_names if pipe != "ner"] |     other_pipes = [pipe for pipe in nlp.pipe_names if pipe != "ner"] | ||||||
|     with nlp.disable_pipes(*other_pipes):  # only train NER |     with nlp.disable_pipes(*other_pipes):  # only train NER | ||||||
|         optimizer = nlp.begin_training() |         # reset and initialize the weights randomly – but only if we're | ||||||
|  |         # training a new model | ||||||
|  |         if model is None: | ||||||
|  |             nlp.begin_training() | ||||||
|         for itn in range(n_iter): |         for itn in range(n_iter): | ||||||
|             random.shuffle(TRAIN_DATA) |             random.shuffle(TRAIN_DATA) | ||||||
|             losses = {} |             losses = {} | ||||||
|  | @ -68,7 +71,6 @@ def main(model=None, output_dir=None, n_iter=100): | ||||||
|                     texts,  # batch of texts |                     texts,  # batch of texts | ||||||
|                     annotations,  # batch of annotations |                     annotations,  # batch of annotations | ||||||
|                     drop=0.5,  # dropout - make it harder to memorise data |                     drop=0.5,  # dropout - make it harder to memorise data | ||||||
|                     sgd=optimizer,  # callable to update weights |  | ||||||
|                     losses=losses, |                     losses=losses, | ||||||
|                 ) |                 ) | ||||||
|             print("Losses", losses) |             print("Losses", losses) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user