This is well documented in pytorch tutorials. Here an extract with your solution (agreeing with what @rusty said above):
Preformatted text`To reshape the network, we reinitialize the classifier’s linear layer as model.classifier = nn.Linear(1024, num_classes)
Source: https://pytorch.org/tutorials/beginner/finetuning_torchvision_models_tutorial.html 167