From 5e4312feede7c2511b4d61a5723077c1b16c142d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 27 May 2017 15:47:02 -0500 Subject: [PATCH] Evaluate loaded class, to ensure save/load works --- spacy/cli/train.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/cli/train.py b/spacy/cli/train.py index b25cdcbd5..7bbda5a47 100644 --- a/spacy/cli/train.py +++ b/spacy/cli/train.py @@ -84,11 +84,11 @@ def train(_, lang, output_dir, train_data, dev_data, n_iter=20, n_sents=0, pbar.update(len(docs)) with nlp.use_params(optimizer.averages): - scorer = nlp.evaluate(corpus.dev_docs(nlp, gold_preproc=False)) with (output_path / ('model%d.pickle' % i)).open('wb') as file_: dill.dump(nlp, file_, -1) - - + with (output_path / ('model%d.pickle' % i)).open('rb') as file_: + nlp_loaded = dill.load(file_) + scorer = nlp_loaded.evaluate(corpus.dev_docs(nlp_loaded, gold_preproc=False)) print_progress(i, losses, scorer.scores) finally: print("Saving model...")