Hi. Can you tell me why accuracy of my model decreases when I save  and load it to predict. My accuracy after training is about 88%
I use resnet model of pytorch
model_ft = models.resnet34(pretrained=True)
num_ftrs = model_ft.fc.in_features

# replace the last fc layer with an untrained one (requires grad by default)
model_ft.fc = nn.Linear(num_ftrs, 216)
model_ft = model_ft.to(device)

# uncomment this block for half precision model
# """
model_ft = model_ft.half()


for layer in model_ft.modules():
    if isinstance(layer, nn.BatchNorm2d):
        layer.float()
# """
criterion = nn.CrossEntropyLoss()
optimizer = optim.SGD(model_ft.parameters(), lr=0.01, momentum=0.9)

lrscheduler = optim.lr_scheduler.ReduceLROnPlateau(optimizer, mode='max', patience=3, threshold = 0.9)

I use this code to save the model
PATH = './car_classifier.pth'
torch.save(model_ft.state_dict(), PATH)

then I load it with
image713×172 5.99 KB
Thanks in advanced!