Allow batch size to be set for evaluation in spacy train

This commit is contained in:
Matthw Honnibal 2020-07-01 15:04:36 +02:00
parent f5532757a3
commit c5d12d1a22

View File

@ -332,13 +332,14 @@ def create_evaluation_callback(nlp, optimizer, corpus, cfg):
)
n_words = sum(len(ex.predicted) for ex in dev_examples)
batch_size = cfg.get("evaluation_batch_size", 128)
start_time = timer()
if optimizer.averages:
with nlp.use_params(optimizer.averages):
scorer = nlp.evaluate(dev_examples, batch_size=32)
scorer = nlp.evaluate(dev_examples, batch_size=eval_batch_size)
else:
scorer = nlp.evaluate(dev_examples, batch_size=32)
scorer = nlp.evaluate(dev_examples, batch_size=eval_batch_size)
end_time = timer()
wps = n_words / (end_time - start_time)
scores = scorer.scores