Kumita← Open visual lesson

Prediction

The math behind the picture

Softmax left us with one share per class. A prediction is one label, so something must choose; and a separate piece of information must tell us whether the choice was right.

Connection 1 of 4

Find the position of the largest share

Argmax returns position 0; the label list, in the same order, names it: labels[0] = watermelon. A shuffled list would make the same position name mug.
From guided stage 3 · Static lesson frame

Argmax returns position 0; the label list, in the same order, names it: labels[0] = watermelon. A shuffled list would make the same position name mug.

Labels (watermelon, fried egg, mug, no target object) are positions 0 to 3. The hand-set logits (2.1, 0.4, −0.6, 0.8) give shares 65.7%, 12.0%, 4.4% and 17.9%.

The largest share is 65.7%. Argmax does not return 65.7%; it returns where it sits, position 0. The label list, in the same order, names position 0: watermelon. That name is the predicted label.

argmax(0.6568, 0.1200, 0.0441, 0.1790) = 0, labels[0] = watermelon

Read it as: max gives the largest value; argmax gives its position; the label list gives the name.

Connection 2 of 4

The largest need not be a majority

Set B: watermelon wins with 39.7 %, below the 50 % line; the other three labels together hold 60.3 %.
From guided stage 4 · Static lesson frame

Set B: watermelon wins with 39.7 %, below the 50 % line; the other three labels together hold 60.3 %.

With logits (1.0, −0.4, 0.0, 0.9) the shares are 39.7%, 9.8%, 14.6% and 35.9%. Watermelon wins with less than half; the other three together hold 60.3%.

Softmax gives a larger logit a larger share, so argmax of the logits and argmax of the shares always pick the same position.

argmaxₖ zₖ = argmaxₖ softmax(z)ₖ

Read it as: Softmax keeps the order, so it never changes the winner.

Connection 3 of 4

Decide on full values, and declare a tie rule

Set D: an exact tie at positions 0 and 3. The declared rule (first tied position in the label order) gives watermelon; with no target object listed first, the same rule gives no target object.
From guided stage 7 · Static lesson frame

Set D: an exact tie at positions 0 and 3. The declared rule (first tied position in the label order) gives watermelon; with no target object listed first, the same rule gives no target object.

Logits (1.1, −0.2, 0.3, 1.1004) give watermelon 0.367342 and no target object 0.367489: both display as 36.7%, but argmax compares the full values and returns position 3.

Logits (1.1, −0.2, 0.3, 1.1) give an exact tie. The rule alone cannot pick, so the code declares one: the first tied position in the label order, here watermelon. This is a convention, not evidence; listing no target object first would make the same rule report it.

Connection 4 of 4

Correctness needs a reference

The reference label, watermelon, is supplied with the picture. Set A predicts watermelon (correct); set E, chosen to show a mistake, predicts fried egg at 76.0 % (wrong).
From guided stage 8 · Static lesson frame

The reference label, watermelon, is supplied with the picture. Set A predicts watermelon (correct); set E, chosen to show a mistake, predicts fried egg at 76.0 % (wrong).

The reference label, watermelon, is supplied with the picture, never computed from the scores. The first prediction matches it, so it is correct.

Logits (0.3, 2.5, −0.4, 0.6), chosen to show a mistake, give fried egg 76.0%: the prediction is fried egg and it is wrong. A large share is not proof of correctness, and one example is not an accuracy.

correct = (predicted label = reference label)

Read it as: Correctness compares two labels; it never looks at the shares.

Connect it back to the picture

The model supplies scores, a decision rule (here argmax with a declared tie rule) selects one label, and an independent reference lets us judge that decision. The label is for the whole input: it does not say where the object is.

Full notation and technical reference

The expressions below collect the operations discussed above. You can return here when you want the compact notation.

k̂ = argmaxₖ pₖ = argmaxₖ zₖ
predicted label = labels[k̂]
  • zₖ is the logit of class k and pₖ = softmax(z)ₖ its share. Softmax keeps the order, so both argmaxes give the same position.
  • argmax returns a position, not the largest value. Ties are settled by a declared rule: here, the first tied position in the label order.

Numerical reference

Labels (watermelon, fried egg, mug, no target object), hand-set logits (2.1, 0.4, −0.6, 0.8), shares 65.7%, 12.0%, 4.4%, 17.9%: argmax is position 0, watermelon, which matches the supplied reference watermelon. With logits (1.0, −0.4, 0.0, 0.9) watermelon still wins with 39.7%, below one half. With (0.3, 2.5, −0.4, 0.6), fried egg gets 76.0% and the prediction is wrong.

Where this explanation stops

The scores are hand-set demonstration scores, not a trained recognizer. Argmax is for single-label multiclass choice; multilabel or abstaining classifiers use other rules. A large share is not proof of correctness, one example is not an accuracy, and the label says nothing about where the object is.

Follow the same idea in the Python or JavaScript notebook →