Reload model, accuracy changed

I have an interesting observation. If I save a model by using, “models.pth”) and reload it. Then the test accuracy changes. Here is the code I am using

#save the model
net = torch.load("wideresnet.pth"), "wideresnetState.pth")

# reload it
net1 = wrn.WideResNet(depth=28, num_classes = 10, widen_factor=10, dropRate=0.0)
net1 = torch.nn.DataParallel(net1, device_ids=[CUDA_DEVICE]).cuda(CUDA_DEVICE)

The test accuracy of “net” is 96.29% while the the test accuracy of “net1” is 94.99%.

Are they both in eval mode?

yes, they are. I guess here they just have one mode.

net1 over here is likely in .train() mode (they are by default). It will matter for BatchNorm.
You’ll have to set net1 to eval mode using net1.eval()