This Optimization concept is the current object: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Optimization
Label Smoothing & Soft Targets
Replace one-hot labels with soft targets to reduce overconfidence, improve calibration, and sometimes boost generalization.
Concept Structure
Label Smoothing & Soft Targets
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Commit a prediction against the code witness.
Learner Contract
What this page should let you do.
1 prerequisite listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and answer the prediction probe against the code witness.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Claim review not recorded
No structured claim checks yet; source metadata is not enough to establish support.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
One-hot labels say: "the correct class is 100% class k, 0% everything else."
In the real world, that level of certainty is often wrong:
- labels can be noisy,
- classes can overlap,
- a training set might not capture all variations.
If we train a model to match one-hot labels perfectly, we also train it to become overconfident. Overconfidence hurts calibration (probabilities stop meaning what they claim), and it can make models brittle under distribution shift.
Label smoothing is the simplest fix: keep the correct class highest, but allocate a small amount of probability mass to other classes.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be a one-hot target and a smoothing strength. Define a smoothed target:
If are the predicted probabilities, cross-entropy becomes:
The gradient w.r.t. logits is:
So compared to one-hot training (where the gradient is ), label smoothing:
- reduces the incentive to push logits to ,
- acts like a small regularizer against extreme confidence.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
def softmax(z):
z = z - z.max()
e = np.exp(z)
return e / e.sum()
z = np.array([3.0, 1.0, -0.5, -1.0]) # logits
p = softmax(z)
K, y = 4, np.array([1.0, 0.0, 0.0, 0.0])
for alpha in [0.0, 0.1]:
y_s = (1 - alpha) * y + alpha * np.ones(K) / K
grad = p - y_s
loss = -float(np.sum(y_s * np.log(p + 1e-12)))
print("alpha =", alpha, "loss =", round(loss, 4), "grad =", np.round(grad, 3))
04
Interactive Demo
Use the authored prediction probe to test the mechanism without a live widget.
Prediction check: before running the loop, predict which class logit gets a smaller-magnitude gradient when alpha changes from 0.0 to 0.1. Then compare the printed gradients and explain how smoothing changes the push toward extreme confidence.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Replace one-hot labels with soft targets to reduce overconfidence, improve calibration, and sometimes boost generalization.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Label Smoothing & Soft Targets should make visible.
Visual Inquiry
Make the image answer a mathematical question
Replace one-hot labels with soft targets to reduce overconfidence, improve calibration, and sometimes boost generalization.
Which visible object should carry the first intuition?
Pick the cue that should make Label Smoothing & Soft Targets easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Add source metadata before treating this page as source-grounded.
Claim Review
Replace one-hot labels with soft targets to reduce overconfidence, improve calibration, and sometimes boost generalization.
Source IDs and witness objects are attached for review; they are not proof by themselves.
Add source metadata before claiming support.
Use equation, code, and demo objects to check whether the source support is operational.
Source support candidates
No structured source note is attached yet.
Practice Loop
Try the idea before it explains itself
Replace one-hot labels with soft targets to reduce overconfidence, improve calibration, and sometimes boost generalization.
Before touching the demo, predict one visible change that should happen in Label Smoothing & Soft Targets.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
Label Smoothing & Soft Targets
What is the smallest example that makes Label Smoothing & Soft Targets click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:optimization/label-smoothing.
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Label Smoothing & Soft Targets Object key: concept:optimization/label-smoothing Context: Optimization Anchor id: concept/concept-notebook/optimization/label-smoothing Open question: What is the smallest example that makes Label Smoothing & Soft Targets click without losing the math? Evidence to inspect: - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/optimization/label-smoothing
concept:optimization/label-smoothing