It is common to customize a pretrained model by delete the output layer or replace it to the output layer that suits your use case. There are several ways to achieve this in PyTorch.
Replace the Fully Connected Layer with an Identity Layer¶
Define an identity layer.
Replace the fully connected layer with an Identity Layer (using ResNet18 as an example).