From d3ffe4ca63bc2e581e30f115b74377b1f3f4c753 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 27 Aug 2020 18:56:58 +0200 Subject: [PATCH] Fix error when tagger was initialized with no labels --- spacy/pipeline/tagger.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/pipeline/tagger.pyx b/spacy/pipeline/tagger.pyx index 2255a585a..af24bf336 100644 --- a/spacy/pipeline/tagger.pyx +++ b/spacy/pipeline/tagger.pyx @@ -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