Learn about the model evaluation process.

How to evaluate the model

How can we evaluate the model? We can compute the validation loss, that is, how wrong the model’s predictions for unseen data are.

First, we need to use the model to compute predictions, and then use the loss function to compute the loss, given our predictions and the true labels. Sounds familiar? These are pretty much the first two steps of the training step function we have built as helper function #1.

So, we can use that code as a starting point, getting rid of its steps 3 and 4. And, most importantly, we need to use the model’s eval() method. The only thing it does is set the model to evaluation mode (just like its train() counterpart did), so the model can adjust its behavior accordingly when it has to perform some operations like Dropout.

Get hands-on with 1200+ tech skills courses.