Optimization

Label Smoothing & Soft Targets

Replace one-hot labels with soft targets to reduce overconfidence, improve calibration, and sometimes boost generalization.

status: reviewimportance: importantdifficulty 2/5math: undergraduateread: 12mprediction probe

Concept Structure

Label Smoothing & Soft Targets

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Commit a prediction against the code witness.

1prerequisites
1next concepts
2related links

Learner Contract

What this page should let you do.

You are here becauseReplace one-hot labels with soft targets to reduce overconfidence, improve calibration, and sometimes boost generalization.

This Optimization concept is the current object: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.

Before thisCross-Entropy

1 prerequisite listed; refresh them before leaning on the math or code.

By the end4/4 sections ready | code witness expected | prediction probe

Explain the mechanism, trace the main notation, and answer the prediction probe against the code witness.

Do this firstIntuition

Read the intuition before the notation; the math should name a mechanism you already felt.

Test the linkUse the prediction probe to commit to the mechanism before moving on.Then continue to Knowledge Distillation: Learning from Teachers

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.
Claims0/0 reviewed
Sources0 cited
Codeattached
Demoplanned
Reviewednot recorded
Updatedpage 2026-06-29

Object flow

4/4 sections readyAsk about thisResearch room
ConceptLabel Smoothing & Soft TargetsOptimization
Local snapshot ready
concept:optimization/label-smoothing
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

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

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Let y{0,1}Ky\in\{0,1\}^K be a one-hot target and α[0,1]\alpha\in[0,1] a smoothing strength. Define a smoothed target:

ysmooth=(1α)y+αK1.y_{\mathrm{smooth}} = (1-\alpha)\,y + \frac{\alpha}{K}\,\mathbf 1.

If p=softmax(z)p = \mathrm{softmax}(z) are the predicted probabilities, cross-entropy becomes:

L=k=1Kysmooth,klogpk.\mathcal L = -\sum_{k=1}^K y_{\mathrm{smooth},k}\,\log p_k.

The gradient w.r.t. logits is:

Lz=pysmooth.\frac{\partial \mathcal L}{\partial z} = p - y_{\mathrm{smooth}}.

So compared to one-hot training (where the gradient is pyp-y), label smoothing:

  • reduces the incentive to push logits to ±\pm\infty,
  • acts like a small regularizer against extreme confidence.
03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
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

04

Interactive Demo

Use the authored prediction probe to test the mechanism without a live widget.

Section prompt

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.

Demo notes open01 / Intuition
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

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.

4/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

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.

Source gapNo canonical references are listed yet.

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.

StatusSubstantive claim review pending

Source IDs and witness objects are attached for review; they are not proof by themselves.

SourcesNo references

Add source metadata before claiming support.

Witnesses3 local objects

Use equation, code, and demo objects to check whether the source support is operational.

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.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in Label Smoothing & Soft Targets.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Object research drawerClose
ConceptLabel Smoothing & Soft TargetsOptimization

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.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptOptimization

Label Smoothing & Soft Targets

Anchored question

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
Local action draft

This draft stays locally in this browser for concept:optimization/label-smoothing.

No local draft saved.
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
Grounded AI handoff

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.

Open source object
concept/concept-notebook/optimization/label-smoothing concept:optimization/label-smoothing