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

Connected

Exercise

Gradient accumulation with Trainer

You're setting up Trainer for your language translation model to use gradient accumulation, so that you can effectively train on larger batches. Your model will simplify translations by training on paraphrases from the MRPC dataset. Configure the training arguments to accumulate gradients! The exercise will take some time to run with the call to trainer.train().

The model, dataset, and compute_metrics() function have been pre-defined.

Instructions

100 XP
  • Set the number of gradient accumulation steps to two.
  • Pass in the training arguments to Trainer.