Model accuracy lower after loading

Answering myself, the resolution is to call learn.model.eval() after learn.load() to put the model into evaluation mode (fix batchnorm and dropout layers).

This is not the first time I stumble over this and quite obviously I’m not the only one to be tripped by forgetting model.eval(). My question then is, why does a library as good as fastai at abstracting away standard and boilerplate code not automatically set the model into evaluation mode when .get_preds()is called? Doesn’t getting predictions imply that I want to evaluate my model instead of training it? Is this behavior on purpose?

3 Likes