Fix tagger initialization

This commit is contained in:
Matthew Honnibal 2020-09-01 16:38:34 +02:00
parent 046c38bd26
commit 4cce32f090

View File

@ -289,7 +289,14 @@ class Tagger(Pipe):
err = Errors.E1006.format(name="Tagger")
raise ValueError(err)
self.set_output(len(self.labels))
self.model.initialize(X=doc_sample)
if doc_sample:
label_sample = [
self.model.ops.alloc2f(len(doc), len(self.labels))
for doc in doc_sample
]
self.model.initialize(X=doc_sample, Y=label_sample)
else:
self.model.initialize()
if sgd is None:
sgd = self.create_optimizer()
return sgd