Ravindra BagaleCourses & study guides मराठी Track your progress

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

  1. make_batch(64) as test.
  2. Predict argmax classes.
  3. 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

Synthetic easy task = learning the API. Real photos need more data + augmentation later.