开始使用免费开始使用

Running the Lightning Trainer

Now that you have your model defined, you are ready to configure the Lightning Trainer to run a training loop. This exercise helps you understand how to integrate your model, data loaders, and training configurations - mastering this setup is essential before moving on to more advanced training.

The torch and lightning.pytorch, imported as pl, have been preloaded for you. A model has already been initialized, using the class you defined in the previous exercise.

本练习是课程的一部分

Scalable AI Models with PyTorch Lightning

查看课程

练习说明

  • Configure the Trainer with 3 epochs.
  • Start a training run with the predefined model.

交互式实操练习

通过完成这段示例代码来试试这个练习。

from lightning.pytorch import Trainer
# Configure the Trainer with max epochs
trainer = ____(max_epochs=____, devices=1)
# Start training with the predefined model
trainer.____(____, train_dataloader, val_dataloader)
编辑并运行代码