-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding new labels to an existing text categorizer #2953
Comments
Are you sure the textcat model is actually trained? It seems to not know how many labels it has, which suggests to me no labels were added before There might also be bugs with adding a label after training --- generally I would advise against that workflow if possible, as it's much harder to ensure results are good. |
Yes I'm sure it's trained, as I get
I believe the problem may be that in |
v2.1 now raises a better error on this. The functionality might be added in future, but at the moment you can't add labels to a pre-trained |
"but at the moment you can't add labels to a pre-trained TextCategorizer model." is this still the case ? |
@arunrajarao Yes, but spaCy should raise a better error now: import spacy
nlp = spacy.blank("en")
textcat = nlp.create_pipe("textcat")
textcat.add_label("TEST1")
nlp.add_pipe(textcat)
nlp.begin_training()
textcat.add_label("TEST2")
|
Is this still the case? Is there a way to add a new label to a trained multi label text classifier with spacy? Through
|
Since v3.1, we do have some resizable So I'll go ahead and close out this issue :-) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
How to reproduce the behaviour
We need to generate a dummy textcat model, so copy and paste the
main
method ofspaCy/examples/training/train_textcat.py
, add an extrareturn nlp
as the last line so we capture the trained model, then doExpected behavior
I would expect that this succeeds and now we have a text classifier that has an additional possible label. Even though this new label wouldn't be returned by the previously trained model, we should be able to train the new model with data with "test" labels.
Actual behavior
Instead, it throws an error:
Digging through the source it seems the problem is that in the
TextCategorizer.add_label
function it takes the last layer of the modelself.model.layers[-1]
and assumes it is assumes it has shape(<int>, <int>)
, but the last layer has shape(<int>, None)
instead.Your Environment
The text was updated successfully, but these errors were encountered: