A “classifier” in some CNNs such as VGG, ResNet etc. contains a few linear layers with activation functions between them. I’m not sure, if your self.classifier is supposed to work like that and to use the extracted features to output the predictions. If that’s the case, I wouldn’t use a complete pretrained model at this point.


This should be possible and you could use e.g. a flag inside the forward method to switch between different branches. However, you should also consider the validation or deployment use case, where you might now have the information where the sample is coming from.