From 047f3ba10c214cf2e136ea5b0bbaa28c7c504e8d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 28 Aug 2020 16:16:03 +0200 Subject: [PATCH] Try to be aware of listeners in begin_training --- spacy/pipeline/tagger.pyx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spacy/pipeline/tagger.pyx b/spacy/pipeline/tagger.pyx index 0de77806e..c57107fe3 100644 --- a/spacy/pipeline/tagger.pyx +++ b/spacy/pipeline/tagger.pyx @@ -293,9 +293,18 @@ class Tagger(Pipe): ] for y in label_sample: y[:, 0] = 1.0 - self.model.initialize(X=doc_sample, Y=label_sample) else: - self.model.initialize() + label_sample = None + if pipeline is not None: + for name, component in pipeline: + if component is self: + break + if hasattr(component, "pipe"): + doc_sample = list(component.pipe(doc_sample, batch_size=8)) + else: + doc_sample = [component(doc) for doc in doc_sample] + + self.model.initialize(X=doc_sample, Y=label_sample) if sgd is None: sgd = self.create_optimizer() return sgd