From 13067095a1ad788438eae086aed7c16b694e61b1 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 16 Mar 2018 12:33:33 +0100 Subject: [PATCH] Disable broken add-after-train in textcat --- spacy/pipeline.pyx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index 7a41085e4..3a96110f9 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -933,6 +933,15 @@ class TextCategorizer(Pipe): if label in self.labels: return 0 if self.model not in (None, True, False): + # This functionality was available previously, but was broken. + # The problem is that we resize the last layer, but the last layer + # is actually just an ensemble. We're not resizing the child layers + # -- a huge problem. + raise ValueError( + "Cannot currently add labels to pre-trained text classifier. " + "Add labels before training begins. This functionality was " + "available in previous versions, but had significant bugs that " + "let to poor performance") smaller = self.model._layers[-1] larger = Affine(len(self.labels)+1, smaller.nI) copy_array(larger.W[:smaller.nO], smaller.W)