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.
Questo esercizio fa parte del corso
Introduction to Deep Learning with PyTorch
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# 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 += ____