Bugfix example script train_ner_standalone.py, fails after training

This commit is contained in:
Jeffrey Gerard 2017-10-12 11:39:12 -07:00
parent 908f44c3fe
commit 39d3cbfdba
1 changed files with 2 additions and 4 deletions

View File

@ -142,16 +142,14 @@ def train(nlp, train_examples, dev_examples, nr_epoch=5):
inputs, annots = zip(*batch)
nlp.update(list(inputs), list(annots), sgd, losses=losses)
scores = nlp.evaluate(dev_examples)
report_scores(i, losses['ner'], scores)
scores = nlp.evaluate(dev_examples)
report_scores(channels, i+1, loss, scores)
report_scores(i+1, losses['ner'], scores)
def report_scores(i, loss, scores):
precision = '%.2f' % scores['ents_p']
recall = '%.2f' % scores['ents_r']
f_measure = '%.2f' % scores['ents_f']
print('%d %s %s %s' % (int(loss), precision, recall, f_measure))
print('Epoch %d: %d %s %s %s' % (i, int(loss), precision, recall, f_measure))
def read_examples(path):