Did you modify the resnet50 from torchvision?
According to your error, the output of the last fc layer is 18452 dim, the output dim in original resnet50 is 1000. I think you should check the shape of the weight of fc layer and find where the mismatch error occurs.
P.S. please format your code with two ```