48. Small CNN Image Project in PyTorch
48.4 Holdout Check
Why. Always check a fresh batch — Chapter 38 overfit lesson applies to nets too.
What. Build a new batch with the same rules; evaluate with model.eval() and torch.no_grad().
How.
Holdout check
- make_batch(64) as test.
- Predict argmax classes.
- Print accuracy.
model.eval()
X_test, y_test = make_batch(64)
with torch.no_grad():
pred = model(X_test).argmax(1)
print("test acc", float((pred == y_test).float().mean()))
Ravindra Bagale's Tip
This easy synthetic task is mainly for learning the PyTorch API. Real photos will need much more data, and later also data augmentation, which means making extra training images by flipping, rotating or cropping them.
Ravindra Bagale's Tip – मराठी
हा सोपा synthetic task मुख्यतः PyTorch API शिकण्यासाठी आहे. Real photos साठी खूप जास्त data लागेल, आणि नंतर data augmentation सुद्धा, म्हणजे images flip, rotate किंवा crop करून जास्तीच्या training images बनवणे.
Ravindra Bagale's Tip – हिंदी
यह आसान synthetic task मुख्य रूप से PyTorch API सीखने के लिए है. Real photos के लिए बहुत ज़्यादा data चाहिए होगा, और बाद में data augmentation भी, यानी images को flip, rotate या crop करके extra training images बनाना.