Multi-label text classification

Hello! I have the same question for multi-label text classification but I would like to apply fastai.text.

I replace in section Classifier tokens from Lesson 10 the number of classes:

# tok_trn, trn_labels = get_all(df_trn, 1)
tok_val, val_labels = get_all(df_val, 166)

and in the section Classifier

#c=int(trn_labels.max())+1
c = int(trn_labels.shape[1])

I get an error:

RuntimeError: multi-target not supported at /opt/conda/conda-bld/pytorch_1512387374934/work/torch/lib/THCUNN/generic/ClassNLLCriterion.cu:16

Then I tried to replace the loss function by adding:

learn.crit = F.binary_cross_entropy_with_logits

and I get another error:

RuntimeError: Expected object of type Variable[torch.cuda.FloatTensor] but found type Variable[torch.cuda.LongTensor] for argument #1 'other'

Any ideas?

1 Like