How to change transfer learning model for a lot of classes

You can alter the particular layer of pretrained model once it is loaded.

Refer this answer for more information.
https://discuss.pytorch.org/t/how-to-delete-layer-in-pretrained-model/17648/6?u=mahi

And if the accuracy is lower, you can add some layers before the last one and train it few more epochs by freezing the pretrained layers.

Hope it helps!.