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.
Latihan ini adalah bagian dari kursus
Introduction to Deep Learning with PyTorch
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# 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 += ____