45. Your First Neural Network in PyTorch
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
model.eval()सेट करा.- Graph नको म्हणून
torch.no_grad(). - 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.
Ravindra Bagale's Tip – मराठी
Predictions करण्याआधी model.eval() call करा आणि code torch.no_grad() च्या आत चालवा. हे दोन्ही मिळून model ला inference mode मध्ये ठेवतात, जो training mode पेक्षा वेगळा आहे, म्हणून ही सवय पक्की करा.
Ravindra Bagale's Tip – हिंदी
Predictions करने से पहले model.eval() call करो और code को torch.no_grad() के अंदर चलाओ. ये दोनों मिलकर model को inference mode में रखते हैं, जो training mode से अलग है, इसलिए यह आदत पक्की करो.