Disable broken add-after-train in textcat

This commit is contained in:
Matthew Honnibal 2018-03-16 12:33:33 +01:00
parent 565ef8c4d8
commit 13067095a1
1 changed files with 9 additions and 0 deletions

View File

@ -933,6 +933,15 @@ class TextCategorizer(Pipe):
if label in self.labels: if label in self.labels:
return 0 return 0
if self.model not in (None, True, False): 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] smaller = self.model._layers[-1]
larger = Affine(len(self.labels)+1, smaller.nI) larger = Affine(len(self.labels)+1, smaller.nI)
copy_array(larger.W[:smaller.nO], smaller.W) copy_array(larger.W[:smaller.nO], smaller.W)