Pytorch Pre-trained RESNET18 Model

1.1k Views Asked by At

I have trained a pre-trained RESNET18 model in pytorch and saved it. While testing the model is giving different accuracy for different mini-batch size. Does anyone know why?

1

There are 1 best solutions below

1
On BEST ANSWER

Yes, I think so. RESNET contains batch normalisation layers. At evaluation time you need to fix these; otherwise the running means are continuously being adjusted after processing each batch hence giving you different accuracy .

Try setting:

model.eval()

before evaluation. Note before getting back into training, call model.train().