Ok, now try doing the same thing but with resnet
from torchvision import models
import torch.nn as nn

m = models.resnet18()
m.fc = nn.Linear(512, 10)
print(m) # see if the last layer was modified

If the last layer is correctly modified, then there is an inconsistency with what you have written in the first message, and we might be missing information to help you further debug your problem