mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-30 23:47:31 +03:00 
			
		
		
		
	change finally block
This commit is contained in:
		
							parent
							
								
									33b39baf61
								
							
						
					
					
						commit
						bce15df01c
					
				|  | @ -181,7 +181,7 @@ def test_pretraining_tok2vec_characters(objective): | ||||||
|         pretrain(filled, tmp_dir) |         pretrain(filled, tmp_dir) | ||||||
|         assert Path(tmp_dir / "model0.bin").exists() |         assert Path(tmp_dir / "model0.bin").exists() | ||||||
|         assert Path(tmp_dir / "model4.bin").exists() |         assert Path(tmp_dir / "model4.bin").exists() | ||||||
|         assert Path(tmp_dir / "model_last.bin").exists() |         assert Path(tmp_dir / "model-last.bin").exists() | ||||||
|         assert not Path(tmp_dir / "model5.bin").exists() |         assert not Path(tmp_dir / "model5.bin").exists() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -238,7 +238,7 @@ def test_pretraining_tagger_tok2vec(config): | ||||||
|         pretrain(filled, tmp_dir) |         pretrain(filled, tmp_dir) | ||||||
|         assert Path(tmp_dir / "model0.bin").exists() |         assert Path(tmp_dir / "model0.bin").exists() | ||||||
|         assert Path(tmp_dir / "model4.bin").exists() |         assert Path(tmp_dir / "model4.bin").exists() | ||||||
|         assert Path(tmp_dir / "model_last.bin").exists() |         assert Path(tmp_dir / "model-last.bin").exists() | ||||||
|         assert not Path(tmp_dir / "model5.bin").exists() |         assert not Path(tmp_dir / "model5.bin").exists() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -80,8 +80,8 @@ def pretrain( | ||||||
| 
 | 
 | ||||||
|     # TODO: I think we probably want this to look more like the |     # TODO: I think we probably want this to look more like the | ||||||
|     # 'create_train_batches' function? |     # 'create_train_batches' function? | ||||||
|     for epoch in range(epoch_resume, P["max_epochs"]): |  | ||||||
|     try: |     try: | ||||||
|  |         for epoch in range(epoch_resume, P["max_epochs"]): | ||||||
|             for batch_id, batch in enumerate(batcher(corpus(nlp))): |             for batch_id, batch in enumerate(batcher(corpus(nlp))): | ||||||
|                 docs = ensure_docs(batch) |                 docs = ensure_docs(batch) | ||||||
|                 loss = make_update(model, docs, optimizer, objective) |                 loss = make_update(model, docs, optimizer, objective) | ||||||
|  | @ -98,7 +98,7 @@ def pretrain( | ||||||
|                 _save_model(epoch) |                 _save_model(epoch) | ||||||
|             tracker.epoch_loss = 0.0 |             tracker.epoch_loss = 0.0 | ||||||
|     finally: |     finally: | ||||||
|             _save_model(epoch, is_last=True) |         _save_model(P["max_epochs"], is_last=True) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def ensure_docs(examples_or_docs: Iterable[Union[Doc, Example]]) -> List[Doc]: | def ensure_docs(examples_or_docs: Iterable[Union[Doc, Example]]) -> List[Doc]: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user