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

Connected

Exercise

Adafactor with Accelerator

You've demonstrated a proof-of-concept of Adafactor with Trainer to train your language translation model with reduced memory requirements. Now you'd like to customize your training loop using Accelerator. Build the training loop to use Adafactor!

The compute_optimizer_size() function has been pre-defined. Some training objects have been pre-loaded: model, train_dataloader, and accelerator.

Instructions

100 XP
  • Pass the model parameters to Adafactor when defining the optimizer.
  • Pass in the optimizer state to print the size.