1. Learn
  2. /
  3. Courses
  4. /
  5. Efficient AI Model Training with PyTorch

Connected

Exercise

Building a training loop with Accelerator

You're ready to implement a training loop for your language translation service. Now that you've seen how Accelerator modifies a PyTorch loop for distributed training you can leverage the Accelerator class in your training loop!

Some data has been pre-loaded:

  • accelerator is an instance of Accelerator
  • train_dataloader, optimizer, model, and lr_scheduler have been defined and prepared with Accelerator

Instructions

100 XP
  • Call the optimizer to zero the gradients.
  • Update the model's parameters.
  • Update the learning rate of the optimizer.