Models are pretrained on ImageNet which has way too many classes.We are fine tuning the entire network but the example only has 2 classes (bees and ants) thus we change the last layer to only output 2 probabilities.


I think the actual code should be model_ft.fc = nn.Linear(num_ftrs, 2). It is basically creating a fc layer connecting all the input features to a linear layer with 2 output. You can add another and intermediate fc to give you 100 features.


As I said unless you are fixing all the model parameters (change requires_grad to False), you are actually fine tuning the entire model and not just the last layer.