Why is Fastai creating four classes (multilabel) when there are only three?

Hi there.

This is the indented behavior for fastAI; you provide four classes to train against, you get four possible results.

If you do not want to see results for you null class (or do not want to name it ‘no cat’) the best way is to exclude it from the training.
As you can see here Lesson 3 - Unknown Labels (Pets Revisited) | walkwithfastai if the algorithm attempts to recognize something unknown, in your case no cat at all, it should return [].

Regarding this question you could read up on How to use BCEWithLogitsLossFlat in lesson1-pets.ipynb or even this one Handle data that belongs to classes not seen in training or testing - #28 by cudawarped

Regarding the sigmoid/softmax-y behaviour - from what I know ResNet50 has a last layer softmax, It should be a Sigmoid when using BCEWith…, according to the last link above, but you could check this again with learn.summary()?

2 Likes