Fix error when tagger was initialized with no labels

This commit is contained in:
Matthew Honnibal 2020-08-27 18:56:58 +02:00
parent e1e1760fd6
commit d3ffe4ca63
1 changed files with 4 additions and 1 deletions

View File

@ -286,7 +286,10 @@ class Tagger(Pipe):
for tag in sorted(tags):
self.add_label(tag)
self.set_output(len(self.labels))
self.model.initialize(X=doc_sample)
if self.labels:
self.model.initialize(X=doc_sample)
else:
self.model.initialize()
if sgd is None:
sgd = self.create_optimizer()
return sgd