1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Deep Learning with PyTorch

Exercise

Model evaluation

With the training loop sorted out, you have trained the model for 1000 epochs, and it is available to you as net. You have also set up a test_dataloader in exactly the same way as you did with train_dataloader before—just reading the data from the test rather than the train directory.

You can now evaluate the model on test data. To do this, you will need to write the evaluation loop to iterate over the batches of test data, get the model's predictions for each batch, and calculate the accuracy score for it. Let's do it!

Instructions

100 XP
  • Set up the evaluation metric as Accuracy for binary classification and assign it to acc.
  • For each batch of test data, get the model's outputs and assign them to outputs.
  • After the loop, compute the total test accuracy and assign it to test_accuracy.