freecoding.school100% FREE · NO SIGNUP
Tensor TownISSUE #22 of 120

loss functions · mse · cross-entropy

NeuraVSThe Overfit Ogre
Neura saysA loss function measures how wrong the model is — the number training tries to minimize.

The loss quantifies prediction error so the optimizer has something to reduce. Mean squared error (MSE) for regression penalizes big misses heavily; cross-entropy for classification penalizes confident wrong answers. The loss is the objective — choose one that matches your task and what you actually care about, because the model optimizes exactly it (and nothing else).

Power-ups you unlock

The Overfit Ogre attacks — common mistakes

Boss battlePick the right loss for predicting price vs predicting a category.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>regression  → MSE (squared error)
classification → cross-entropy
model minimizes exactly this number</pre></body></html>
▶ Open the interactive comic issue
‹ Activation Functions · Relu · Sigmoid · TanhGradient Descent · The Optimizer ›