Fix #1444: fix pipeline logic and wrong paramater in update call

This commit is contained in:
Jeroen Bobbeldijk 2017-10-22 15:18:36 +02:00
parent 490ad3eaf0
commit 84c6c20d1c

View File

@ -56,8 +56,7 @@ def train_ner(nlp, train_data, output_dir):
losses = {} losses = {}
for batch in minibatch(get_gold_parses(nlp.make_doc, train_data), size=3): for batch in minibatch(get_gold_parses(nlp.make_doc, train_data), size=3):
docs, golds = zip(*batch) docs, golds = zip(*batch)
nlp.update(docs, golds, losses=losses, sgd=optimizer, update_shared=True, nlp.update(docs, golds, losses=losses, sgd=optimizer, drop=0.35)
drop=0.35)
print(losses) print(losses)
if not output_dir: if not output_dir:
return return
@ -100,9 +99,10 @@ def main(model_name, output_directory=None):
) )
] ]
nlp.pipeline.append(TokenVectorEncoder(nlp.vocab)) nlp.add_pipe(TokenVectorEncoder(nlp.vocab))
nlp.pipeline.append(NeuralEntityRecognizer(nlp.vocab)) ner = NeuralEntityRecognizer(nlp.vocab)
nlp.pipeline[-1].add_label('ANIMAL') ner.add_label('ANIMAL')
nlp.add_pipe(ner)
train_ner(nlp, train_data, output_directory) train_ner(nlp, train_data, output_directory)
# Test that the entity is recognized # Test that the entity is recognized