AI by Hand ✍️

AI by Hand ✍️

L2 Loss

Essential AI Math Excel Blueprints

Prof. Tom Yeh's avatar
Prof. Tom Yeh
Feb 14, 2026
∙ Paid

The L2 loss measures how far a model’s output (prediction) vector is from a target vector. It provides a single value that reflects the overall discrepancy between the model’s output and the desired outcome, encouraging predictions that stay close to the true target.

Calculation

To compute the L2 loss between a prediction vector and a target vector, take the difference between their corresponding components, square each difference, sum all the squared values, and then multiply the result by one-half. The one-half factor does not change where the minimum occurs, but it simplifies the gradient during optimization. This produces a single smooth measure of prediction error, where larger discrepancies contribute more strongly due to the squaring.

Excel Blueprint

This Excel Blueprint is available to AI by Hand Academy members. You can become a member via a paid Substack subscription.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2026 Tom Yeh · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture