I load a pretrained vgg16 and written some python script to replace the classifier layer and serialize it in a pt file.
import torchvision.models as models
import torchvision.transforms as transforms
from PIL import Image
import torch.nn as nn
def forward(self, x): return x
model = models.vgg16(weights=“VGG16_Weights.IMAGENET1K_V1”)
model.classifier = Identity()
The pretrained vgg16 file weighs around 500mo, but the file obtained after applying the script weighs 58mo. I have the impression that the weights of the pre-trained vgg16 were not set during serialization. Am I wrong?