BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Introduction to Deep Learning with PyTorch

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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 += ____
Kodu Düzenle ve Çalıştır