mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
Make loading code more consistent in train command
This commit is contained in:
parent
97c9b5db8b
commit
5156074df1
|
@ -114,10 +114,7 @@ def train(cmd, lang, output_dir, train_data, dev_data, n_iter=10, n_sents=0,
|
||||||
util.set_env_log(False)
|
util.set_env_log(False)
|
||||||
epoch_model_path = output_path / ('model%d' % i)
|
epoch_model_path = output_path / ('model%d' % i)
|
||||||
nlp.to_disk(epoch_model_path)
|
nlp.to_disk(epoch_model_path)
|
||||||
nlp_loaded = lang_class(pipeline=pipeline)
|
nlp_loaded = util.load_model_from_path(epoch_model_path)
|
||||||
for name in pipeline:
|
|
||||||
nlp_loaded.add_pipe(nlp.create_pipe(name), name=name)
|
|
||||||
nlp_loaded = nlp_loaded.from_disk(epoch_model_path)
|
|
||||||
dev_docs = list(corpus.dev_docs(
|
dev_docs = list(corpus.dev_docs(
|
||||||
nlp_loaded,
|
nlp_loaded,
|
||||||
gold_preproc=gold_preproc))
|
gold_preproc=gold_preproc))
|
||||||
|
@ -131,11 +128,7 @@ def train(cmd, lang, output_dir, train_data, dev_data, n_iter=10, n_sents=0,
|
||||||
else:
|
else:
|
||||||
gpu_wps = nwords/(end_time-start_time)
|
gpu_wps = nwords/(end_time-start_time)
|
||||||
with Model.use_device('cpu'):
|
with Model.use_device('cpu'):
|
||||||
nlp_loaded = lang_class(pipeline=pipeline)
|
nlp_loaded = util.load_model_from_path(epoch_model_path)
|
||||||
for name in pipeline:
|
|
||||||
nlp_loaded.add_pipe(nlp.create_pipe(name), name=name)
|
|
||||||
|
|
||||||
nlp_loaded = nlp_loaded.from_disk(epoch_model_path)
|
|
||||||
dev_docs = list(corpus.dev_docs(
|
dev_docs = list(corpus.dev_docs(
|
||||||
nlp_loaded, gold_preproc=gold_preproc))
|
nlp_loaded, gold_preproc=gold_preproc))
|
||||||
start_time = timer()
|
start_time = timer()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user