here is my code which loads and test the saved model
data_dir = ‘Classification’
image_datasets = {x: datasets.ImageFolder(os.path.join(data_dir, x),
data_transforms[x])
for x in [‘test’]}
dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=100,
shuffle=True, num_workers=24)
for x in [‘test’]}
print(dataloaders)
dataset_sizes = {x: len(image_datasets[x]) for x in [‘test’]}
class_names = image_datasets[‘test’].classes
device = torch.device(“cuda:0” if torch.cuda.is_available() else “cpu”)
best_acc = 0.0
Each epoch has a training and validation phase
for phase in [‘test’]:
print(“model”)
model = resnet50().to(device)
model.load_state_dict(torch.load('resnet50_4c.pt'))
model.eval()   # Set model to evaluate mode

running_loss = 0.0
running_corrects = 0

# Iterate over data.
for inputs, labels in dataloaders[phase]:
    inputs = inputs.to(device)
    labels = labels.to(device)


    with torch.set_grad_enabled(phase == 'test'):
        outputs = model(inputs)
        _, preds = torch.max(outputs, 1)
        loss = criterion(outputs, labels)

        running_loss += loss.item() * inputs.size(0)
        running_corrects += torch.sum(preds == labels.data)

        loss = running_loss / dataset_sizes[phase]
        acc = running_corrects.double() / dataset_sizes[phase]

        print('{} Loss: {:.4f} Acc: {:.4f}'.format(phase, loss, acc))



    time_elapsed = time.time() - since
    print('Testing complete in {:.0f}m {:.0f}s'.format(
    time_elapsed // 60, time_elapsed % 60))
    print('Best val Acc: {:4f}'.format(acc))