Snd
Snd

Reputation: 3

Pytorch Pre-trained RESNET18 Model

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?

Upvotes: 0

Views: 1147

Answers (1)

mbpaulus
mbpaulus

Reputation: 7691

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().

Upvotes: 1

Related Questions