Writing the evaluation loop
In this exercise, you will write an evaluation loop to compute validation loss. The evaluation loop follows a similar structure to the training loop but without gradient calculations or weight updates.
model, validationloader, and loss function criterion have already been defined to handle predictions, data loading, and loss calculation.
Deze oefening maakt deel uit van de cursus
Introduction to Deep Learning with PyTorch
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Set the model to evaluation mode
____
validation_loss = 0.0
with torch.no_grad():
for features, labels in validationloader:
outputs = model(features)
loss = criterion(outputs, labels)
# Sum the current loss to the validation_loss variable
validation_loss += ____