Ravindra BagaleCourses & study guides English Track your progress

45. Your First Neural Network in PyTorch

Data Science

45.4 Predict with Sigmoid

45.4 Sigmoid ने predict

Training नंतर logits → probabilities आणि decisions.

हे का शिकायचं?

Why. Training नंतर logits ला probabilities आणि decisions मध्ये बदला.

हे काय आहे?

What. torch.sigmoid(logits) → probability. Demo साठी threshold 0.5 → class 0/1.

कसं करायचं?

How.

Predict

  1. model.eval() सेट करा.
  2. Graph नको म्हणून torch.no_grad().
  3. probs आणि hard labels print.
model.eval()
with torch.no_grad():
 logits = model(X)
 probs = torch.sigmoid(logits)
 preds = (probs >= 0.5).float()
print("probs:\n", probs.round(decimals=3))
print("preds:\n", preds)

Ravindra Bagale's Tip

Before you make predictions, call model.eval() and run the code inside torch.no_grad(). Together they put the model in inference mode, which is different from training mode, so make this a strong habit.