Beginning of NLP

Thank you very much sgugger! I tested this on my dataset (in fact, I have 20 labels, not 10).

I was able to train LM without problems, but when I train RNNLearner.classifier I get the following error:

  • ValueError: Target size (torch.Size([8, 20])) must be the same as input size (torch.Size([8, 2])) when I set the batch size to 16.
  • ValueError: Target size (torch.Size([16, 20])) must be the same as input size (torch.Size([16, 2])) when I set the batch size to 32.

I ran this twice:

  1. With dummy label column set to [0]*len(df): link to my GitHub file
  2. Without any dummy column: link to my GitHub file

Am I doing something wrong? And which version is better - 1 or 2? It looks like it would work only if there are just 2 outputs in the last linear layer for the classifier, cause now it cannot match input with the size of 2 and output (target) of the classifier with the size of 20.

Here is also a screenshot:


Btw., I use fastai version 1.0.14 (in new 1.0.15 TextDataset doesn’t even have the method from_csv())

I would appreciate any advice!

1 Like