Configuring the optimizer
Now that we have training logic, we need to specify how to optimize the model's parameters.
In this exercise, you'll complete the configure_optimizers method within a PyTorch Lightning module used for image classification tasks. Your goal is to set up an optimizer that will update the model's parameters during training. To complete this you'll use the Adam optimizer with a learning rate of 1e-3.
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Scalable AI Models with PyTorch Lightning
คำแนะนำการฝึกหัด
- Create an Adam optimizer using the model's parameters, setting the learning rate to
1e-3.
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
import torch
def configure_optimizers(self):
# Create an Adam optimizer for model parameters
optimizer = ____
return optimizer