Hello Anyere!



 Bendrien:

Im building a CNN for sequential data using CrossEntropyLoss. I have 3 classes as output of which two are of interest and the last is used if one of the two wasnt a fitt:


Class 0: no fitt

Class 1: interest 1

Class 2: interest 2

…
Would it make sense to set the ignore_index parameter to my Class 0?


Unless there is something unusual about your classification
problem, I think you should not use ignore_index for Class 0.
Suppose you feed a Class-0 sample to your model (so target
is 0), and your model incorrectly classifies it as Class 2.  You
do want to tell your model not to do this, so you do want this
incorrect classification to add a penalty to your loss function.
If you set ignore_index = 0, this sample (and all other Class-0
samples) will not contribute to the loss function, and so Class-0
misclassifications will not be penalized.
(Because your training data is unbalanced, you may indeed want
to deweight the Class-0 samples in your training set – either by
using CrossEntropyLoss's weight argument, or by sampling
fewer of your Class-0 samples.  But ignoring them altogether goes
too far and would be hiding import information from your model’s
training.)
Good luck!
K. Frank