1. เรียนรู้
  2. /
  3. Courses
  4. /
  5. Efficient AI Model Training with PyTorch

Connected

Exercises

Setting the model in evaluation mode

You're ready to set your language model in evaluation mode. If the model is not in evaluation mode during inference, layers like batch normalization and dropout will introduce changes in the behavior of the model, leading to inconsistent translation quality. Build the loop to evaluate the model!

Some data have been preloaded: model, eval_dataloader, accelerator, and metric.

คำแนะนำ

100 XP
  • Set the model in evaluation mode before looping through batches in the dataset.
  • Aggregate predictions and labels across devices to compute evaluation metrics with Accelerator's .gather_for_metrics() method.
  • Compute the evaluation metric at the end.