Forward pass and logits
What it is
The forward pass evaluates the model from inputs to output using the current parameters; it does not learn anything by itself. For classification, the final raw scores are logits: unnormalised evidence for each class, where a larger logit means the model prefers that class relative to the others. Softmax converts a vector of logits into probabilities only when probabilities are needed for interpretation, while an argmax turns them into a hard prediction for reporting. The forward pass must preserve the batch dimension so every input still has a corresponding output and target.
Why it matters
Keeping logits raw gives stable loss calculations and makes it clear which operation belongs to the model versus the loss function. Logit-based losses use numerically stable formulations that avoid overflow when scores are large. It also separates learning from decision policy: a threshold for an alert can change without retraining the model or pretending that a 0.51 probability is the same as high confidence.
In the real world: Each time a customer uploads a photo, one forward pass turns it into scores for each product category.
Visual example
Deep learningLogits are raw scores; the loss receives them before a hard class decision is made.
import torch.nn as nn
logits = model(images) # (batch, n_classes)
loss = nn.CrossEntropyLoss()(logits, labels) # no softmax here
probs = logits.softmax(dim=1) # only for display or decisionsUsing argmax in the training path. It discards the scores and has no useful gradient; use logits for the loss and reserve argmax for evaluation.