Search⌘ K
AI Features

Deploying / Making Predictions

Explore how to deploy a trained PyTorch model by loading its saved state and preparing it for inference. Understand the importance of setting the model to evaluation mode and transferring inputs to the correct device. This lesson guides you through the steps needed to make accurate predictions with a fully trained model loaded in PyTorch.

Using our model for making predictions

Again, if we are starting fresh as if we had just turned on the computer and started Jupyter, we have to set up the stage before actually loading the model. But, this time, we only need to configure the model:

Shell
# running model configuration V3 script
%run -i model_configuration/v3.py

Once again, we have an untrained model at this point. The loading procedure is simpler though:

  • Load the dictionary back by using torch.load().

  • Load model state dictionary back by using its method load_state_dict().

Since the model is fully trained, we do not need to load the optimizer or anything else. ...