शुरू करेंमुफ़्त में शुरू करें

Implementing the validation step

Once we trained a neural network model we need to monitor its performance during training. Using PyTorch Lightning, implement the validation_step() method to calculate and log the validation loss at each epoch.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Scalable AI Models with PyTorch Lightning

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Compute predictions using the model on input batch.
  • Calculate validation loss using F.cross_entropy().
  • Log the validation loss with self.log() as val_loss.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

import torch.nn.functional as F

def validation_step(self, batch, batch_idx):
    x, y = batch
    # Compute predictions using the model
    preds = ____(x)
    # Calculate validation loss
    loss = F.____(preds, y)
    # Log the validation loss
    self.____('val_loss', loss)
कोड संपादित करें और चलाएँ