A one-hot target collapses the sum before any logarithm is evaluated. The zero target entries drop structurally, leaving only the correct class probability.
highlighted = computed this step
The zero target terms vanish
The target is one-hot, so two entries are exactly 0. Those entries multiply their log terms by zero and drop structurally. The correct class has target entry 1, so only its probability remains in the loss.
yi=0⇒yilog(pi) drops
One term is selected
The selected probability is 1/2. Therefore the full sum collapses exactly to a single named term: minus log of 1/2.
H=−log(1/2)
Summary
The collapse is exact and does not require evaluating a logarithm. One-hot selection is arithmetic structure; the log value remains outside the exact register.