When using PyTorch it is common practice to load and save a model’s state from/to a .pth
file. Doing so allows, for example, to
instantiate an untrained model and load learned parameters coming from another pre-trained model. Once the learned parameters are loaded to the model
it is important, before inferencing, to clearly state the intention by calling torch.nn.Module.eval()
method to set the model in
evaluation mode or calling torch.nn.Module.train()
to indicate the training will resume. Failing to call
torch.nn.Module.eval()
would leave the model in training mode which may not be the intention.