Mixed precision training with Trainer
You want to simplify your training interface for mixed precision training. As an alternative to training loops with Accelerator
, you've decided to build Trainer
since your model doesn't require custom training loops. Set up Trainer
to use mixed precision training! The exercise will take some time to run with the call to trainer.train()
.
This exercise is part of the course
Efficient AI Model Training with PyTorch
Exercise instructions
- Enable mixed precision training for
Trainer
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
training_args = TrainingArguments(
output_dir="./results",
evaluation_strategy="epoch",
# Enable mixed precision training
____=____
)
trainer = Trainer(model=model,
args=training_args,
train_dataset=dataset["train"],
eval_dataset=dataset["validation"],
compute_metrics=compute_metrics)
trainer.train()