Try to be aware of listeners in begin_training

This commit is contained in:
Matthew Honnibal 2020-08-28 16:16:03 +02:00
parent 1b8d2ed14f
commit 047f3ba10c

View File

@ -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