Skip to content
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

Multi-label classification issue #2

Open
rajae-Bens opened this issue Sep 28, 2020 · 2 comments
Open

Multi-label classification issue #2

rajae-Bens opened this issue Sep 28, 2020 · 2 comments

Comments

@rajae-Bens
Copy link

Hi,

thank s for this great tutorial
I want to apply this for a multi label text classification problem. My labels are of this format
tensor([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]])
I changed the softmax function in the bert model by the sigmoid function but when I tried to train the model I got this error
multi-target not supported at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:18

Could u help plz
thank u

@prateekjoshi565
Copy link
Owner

Hi, you don't have to change the softmax function. Just replace the output units from 2 to the number of classes in your dataset in the layer below:

self.fc2 = nn.Linear(512,2)

@rajae-Bens
Copy link
Author

First, thank u for responding. Well, I am confused now because in all tutorials Ive read about multi label classification, they all recommend using sigmoid for this kind of problems. Can u explain more plz
Thank u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants