0PricingLogin
Deep Learning Academy · Lesson

Write a Minimal Training Loop

Loop over data and update weights.

From Steps to a Loop

You know the four moves of one iteration. Now you wrap them in a loop that walks over your data again and again until the model is trained. 🔁

Gather the Ingredients

Before looping you need three things: a model, a loss function, and an optimizer that holds your model's parameters. Set them up once, up front.

loss_fn = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(model.parameters())

All lessons in this course

  1. Forward Pass, Loss, Backward, Step
  2. Write a Minimal Training Loop
  3. Track Accuracy While You Train
  4. Train vs Eval Mode
← Back to Deep Learning Academy