Model Pipeline - Epoch-based training
This pipeline shows how a simple model learns step-by-step by repeating passes over the data called epochs. Each epoch helps the model improve by adjusting itself to make better predictions.
This pipeline shows how a simple model learns step-by-step by repeating passes over the data called epochs. Each epoch helps the model improve by adjusting itself to make better predictions.
Loss
0.7 | *
0.6 | *
0.5 | *
0.4 | *
0.3 | *
0.2 |
+------------
1 2 3 4 5 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.65 | 0.60 | Model starts learning with moderate loss and accuracy |
| 2 | 0.50 | 0.72 | Loss decreases and accuracy improves as model adjusts |
| 3 | 0.40 | 0.80 | Model continues to learn, loss drops further |
| 4 | 0.32 | 0.85 | Good progress, model is more accurate |
| 5 | 0.28 | 0.88 | Loss stabilizes, accuracy nearing high level |
for epoch in range(2):
total_loss = 0
for batch in dataloader:
output = model(batch)
loss = loss_fn(output, batch.labels)
optimizer.zero_grad()
loss.backward()
optimizer.step()
total_loss += loss.item()
print(f"Epoch {epoch+1} loss: {total_loss}")for epoch in range(3):
for batch in dataloader:
output = model(batch)
loss = loss_fn(output, batch.labels)
loss.backward()
optimizer.step()
optimizer.zero_grad()
print(f"Epoch {epoch+1} done")Pass the test and this pattern moves unknown